What is Wscript.Shell?
There is a powerful programming object to interact various aspect of windows shell. You can run executable application , work with the Reigistry and even control Windows' environment variables with the help of Wscript.Shell object. We can call its genric name WshShell.
'Description:
' Function to execute a commond via WScript.Shell
'Input:
' cmdStr: The command to be executed
'Output:
' execute_Shell:
' [false]: The default result of the function
' [stdErrText]: The error message throw out from shell object
' [stdOutText]: The return message from shell object
'Throw Exception When:
' none
public function execute_Shell(cmdStr)
on error resume next
execute_Shell = false
set wshObj = CreateObject("Wscript.Shell")
set wshResult = wshObj.Exec(cmdStr)
stdOutText = wshResult.StdOut.ReadAll()
stdErrText = wshResult.StdErr.ReadAll()
if stdErrText <> "" then
execute_Shell = stdErrText
else
execute_Shell = stdOutText
end if
set wshObj = nothing
on error goto 0
end function