how do I force the script to wait until the first shell.run command
completes?
Hi
Set the Run methods _third_ parameter (bWaitOnReturn) to True when using the WSH
Run method to launch your command shell.
Run method:
http://msdn.microsoft.com/library/en-us/script56/html/wsmthrun.asp
The helpfile for WSH is also available for download
WSH 5.6 documentation download (script56.chm)
http://msdn.microsoft.com/downloads/sample.asp?url=/MSDN-FILES/027/001/728/msdncompositedoc.xml
--
torgeir
Microsoft MVP Scripting and WMI
Porsgrunn Norway
Documentation download:
http://msdn.microsoft.com/downloads/sample.asp?url=/msdn-
files/027/001/728/msdncompositedoc.xml&frame=true
Bill James
Microsoft MVP-DTS
>.
>
"Torgeir Bakken (MVP)" <Torgeir.B...@hydro.com> wrote in message
news:3E00C463...@hydro.com...
> and if I want the wsh script to perform a certain function if the error code
> level of the command that it executes through shell.run is of a certain
> number?
Here is an examole:
Set oShell = CreateObject("WScript.Shell")
strLaunchCmd = "MSIEXEC.EXE /i <msifile> /qb- ALLUSERS=2 REBOOT=Suppress"
intRetVal = oShell.Run(strLaunchCmd, 1, True)
If intRetVal = "3010" Then
MsgBox "Installation was successfull, reboot needed"
ElseIf intRetVal = "1641" Then
MsgBox "MSI installation will continue after boot, reboot is started"
Wscript.Sleep 15000
WScript.Quit
ElseIf intRetVal = "0" Then
MsgBox "Installation was successfull"
Else
MsgBox "Installation was NOT successfull, error code returned: " & intRetVal
End If
I assume this demo code you supplied is for checking error codes on dos
commands.
Are there error codes also generated by wsh commands, like "fso.copyfile
c:\test.txt, d:\test.txt" ?
"Torgeir Bakken (MVP)" <Torgeir.B...@hydro.com> wrote in message
news:3E00E6AA...@hydro.com...
> I assume this demo code you supplied is for checking error codes on dos
> commands.
Yes (or for the more correct naming "command line interface" (CLI) or "command
line utilities", in some other newsgroups you would get flamed for calling it
"dos commands" at least for a WinNT/2k/XP environment ;-)
> Are there error codes also generated by wsh commands, like "fso.copyfile
> c:\test.txt, d:\test.txt" ?
Yes, e.g if you try to copyt a file that des not exist, you will get Microsoft
VBScript runtime error #53, "File not found".
Set oFSO = CreateObject("Scripting.FileSystemObject")
On Error Resume Next ' Turns off internal error checking
oFSO.CopyFile "c:\fghhtejjst.txt", "d:\test.txt"
If Err.Number <> 0 Then
MsgBox "Copy was NOT successful!" & vbCrlf & vbCrlf _
& "error number: " & Err.Number & vbCrlf _
& "error description: " & Err.Description
Err.Clear
End If
On Error Goto 0 ' Turns on internal error checking and also does a Err.Clear
MsgBox "Finished"