Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how to force script to wait for command to finish before proceeding

1 view
Skip to first unread message

Pete

unread,
Dec 18, 2002, 1:45:50 PM12/18/02
to
I want to write a script which executes a virus scan using the command
prompt. I don't want my script to continue executing other portions of the
script until the virus scan is complete.

how do I force the script to wait until the first shell.run command
completes?


Torgeir Bakken (MVP)

unread,
Dec 18, 2002, 1:54:27 PM12/18/02
to
Pete wrote:

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


Bill James

unread,
Dec 18, 2002, 2:16:13 PM12/18/02
to
Run Method: http://msdn.microsoft.com/library/en-
us/script56/html/wsMthRun.asp?frame=true

Documentation download:
http://msdn.microsoft.com/downloads/sample.asp?url=/msdn-
files/027/001/728/msdncompositedoc.xml&frame=true

Bill James
Microsoft MVP-DTS

>.
>

Pete

unread,
Dec 18, 2002, 3:57:48 PM12/18/02
to
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?


"Torgeir Bakken (MVP)" <Torgeir.B...@hydro.com> wrote in message
news:3E00C463...@hydro.com...

Torgeir Bakken (MVP)

unread,
Dec 18, 2002, 4:20:43 PM12/18/02
to
Pete wrote:

> 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

Pete

unread,
Dec 18, 2002, 9:53:11 PM12/18/02
to
Thanks,

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...

Torgeir Bakken (MVP)

unread,
Dec 19, 2002, 1:13:12 AM12/19/02
to
Pete wrote:

> 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"

Pete

unread,
Dec 19, 2002, 1:33:37 AM12/19/02
to
Thanks

"Torgeir Bakken (MVP)" <Torgeir.B...@hydro.com> wrote in message

news:3E016378...@hydro.com...

0 new messages