For Programmers: Free Programming Magazines  


Home > Archive > VBScript > September 2004 > Re: Newby question : How can I run a program say notepad.exe and









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: Newby question : How can I run a program say notepad.exe and
Torgeir Bakken \(MVP\)

2004-09-23, 3:56 pm

Maurice zmau wrote:

> I want to run a program, from a vbScript.
> 1) How do I do this ?
>
> 2) How do I wait for the program's completion ?
>
> Thanks

Hi

'--------------------8<----------------------
Set oShell = CreateObject("WScript.Shell")
oShell.Run "notepad.exe", 1, True
MsgBox "Notes was now closed.", vbOkOnly + vbSystemModal, "Test"
'--------------------8<----------------------

True in the third parameter to the Run method will make it wait for
the process it launches to close.

WSH 5.6 documentation (local help file) can be downloaded from here
if you haven't got it already:
http://msdn.microsoft.com/downloads/list/webdev.asp


--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/sc...er/default.mspx
Torgeir Bakken \(MVP\)

2004-09-26, 3:55 pm

Maurice zmau wrote:

>
>
> Great, how do I retrieve the program's return code ?

Hi

'--------------------8<----------------------
Set oShell = CreateObject("WScript.Shell")
iRC = oShell.Run("some.exe", 1, True)
MsgBox "some.exe was now closed, return code: " & iRC, _
vbOkOnly + vbSystemModal, "Test"
'--------------------8<----------------------


--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/sc...er/default.mspx
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com