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

Run an EXE from vbscript and wait until finished

6,259 views
Skip to first unread message

Rony crijns

unread,
Jan 14, 2004, 3:11:35 AM1/14/04
to
Hi all,
In my VBScript I want to run an EXE. If the EXE is
finished the script should run futher. Problem now is when
I use the following code:

--Begin script
Set WSHShell = CreateObject("WScript.Shell")
result = WSHShell.Run("C:\Program
Files\Lotus\Notes\notes.exe",,True)
msgbox "Thanks for waiting"
--End script

The script does not wait until notes.exe is finished.
Instead: notes.exe is starting up. So far so good.
Notes.exe is asking to login. Now the script is running
futher and shows the messagebox. Meanwhile, Notes.exe is
still running.
If I try it with Notepad.exe it works fine.
Does anybody know how to fix my problem ???

Many thanks,

Rony

Ray at <%=sLocation%>

unread,
Jan 14, 2004, 9:20:42 AM1/14/04
to
See the documentation for the .Run method here
http://msdn.microsoft.com/library/en-us/script56/html/wsMthRun.asp and take
note of the optional arguments. Or download the documentation here
http://www.microsoft.com/downloads/details.aspx?FamilyId=01592C48-207D-4BE1-8A76-1C4099D7BBB9.

Ray at work

"Rony crijns" <anon...@discussions.microsoft.com> wrote in message
news:06d201c3da76$06c166c0$a501...@phx.gbl...

Torgeir Bakken (MVP)

unread,
Jan 14, 2004, 10:48:58 PM1/14/04
to
Rony crijns wrote:

> In my VBScript I want to run an EXE. If the EXE is
> finished the script should run futher. Problem now is when
> I use the following code:
>

> Set WSHShell = CreateObject("WScript.Shell")
> result = WSHShell.Run("C:\Program
> Files\Lotus\Notes\notes.exe",,True)
> msgbox "Thanks for waiting"
>

> The script does not wait until notes.exe is finished.
> Instead: notes.exe is starting up. So far so good.
> Notes.exe is asking to login. Now the script is running
> futher and shows the messagebox. Meanwhile, Notes.exe is
> still running.

Hi

You Run statement is correct, having True as the third parameter. The problem
is with Notes.exe and how it behaves.

If you look in the Process list in Task Manager after Notes is started up, you
will not find Notes.exe, but Nlnotes.exe.

When you start Notes.exe, it does a couple of things, and then it starts
Nlnotes.exe and terminates.

What Is the Difference Between Notes.exe and Nlnotes.exe?
http://www-1.ibm.com/support/docview.wss?uid=swg21092749

<quote>
What is the difference in function between the two executable files, Notes.exe
and Nlnotes.exe? Both of these files are located in the Notes program
directory.

Notes.exe does the following three main things, then calls Nlnotes.exe:

- it displays the splash screen
- checks to see if Notes is already running (and aborts if so)
- loads Qnc.exe if you have it configured to do so.

So, if you load Nlnotes.exe or create a shortcut directly to Nlnotes.exe you
don't have to wait for the splash screen. You can run multiple versions of
Notes simultaneously, and avoid loading the debugger.
</quote>


So to fix your problem, you could bypass Notes.exe and start Nlnotes.exe
instead.

But I would not recommend to start two instances of Notes simultaneously, so
you should check if Nlnotes.exe is already running before launching
Nlnotes.exe, e.g. like this:

sComputer = "." ' use "." for local computer
Set oWmi = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& sComputer & "\root\cimv2")

Set colProcessList = oWmi.ExecQuery _
("Select Name from Win32_Process Where Name = 'nlnotes.exe'")

If colProcessList.Count = 0 Then
Set oShell = CreateObject("WScript.Shell")
oShell.Run """C:\Program Files\Lotus\Notes\nlnotes.exe""",,True
MsgBox "Thanks for waiting"

Else
MsgBox "Notes is already running!"
End If

--
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/scriptcenter


anon...@discussions.microsoft.com

unread,
Jan 15, 2004, 2:28:25 AM1/15/04
to
Thanks for the great tip.
Now it works perfect. But I don't have to check if notes
is already running because this code is in a startup
script. Somewhere else in de script I check if Notes is
configured correctly for that user. If it is not, it wil
NOW executes nlNotes.exe with a configurationfile.
But to check for other instances is also a great tip. I
will use in other different scripts.
Thanks.

>.
>

0 new messages