Chamitha
January 19th, 2003, 10:56 PM
Hi,
I'm a newbie to VBScript and I'm trying to launch an application using the WScript.Shell Run command.
Option Explicit
Dim WshShell
Dim return
Set WshShell = Wscript.CreateObject("Wscript.Shell")
return = WshShell.Run("cmd.exe")
MsgBox(return)
set WshShell = Nothing
I have a couple of questions.
1. How can I capture the return code of the Run command. Although I have used the variable return to capture the code it only displays a message box if the Run command was successful. Otherwise a WSH error message is displayed and script terminates.
2. How can I surpress the WSH error messages? Basically I want my script to capture and handle the return codes of functions without the Windows SCripting Host throwing messages!
If there is any other object other than WScript which can do the same in VBScript please let me know. Thanks!
I'm a newbie to VBScript and I'm trying to launch an application using the WScript.Shell Run command.
Option Explicit
Dim WshShell
Dim return
Set WshShell = Wscript.CreateObject("Wscript.Shell")
return = WshShell.Run("cmd.exe")
MsgBox(return)
set WshShell = Nothing
I have a couple of questions.
1. How can I capture the return code of the Run command. Although I have used the variable return to capture the code it only displays a message box if the Run command was successful. Otherwise a WSH error message is displayed and script terminates.
2. How can I surpress the WSH error messages? Basically I want my script to capture and handle the return codes of functions without the Windows SCripting Host throwing messages!
If there is any other object other than WScript which can do the same in VBScript please let me know. Thanks!