Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Waiting for a program termination 1

Status
Not open for further replies.

LordJudas

Technical User
Apr 18, 2002
11
US
Hi everyone,

I'm writing a VBscript for NT4 SP4 (that means no WMI).
I deploy a package on a desktop, this package set dll registration into KKLM\Soft\MS\WinNT\CurVer\RunOnce then reboot computer.

My script starts with autologon, do some administrative tasks (like applying hotfixes) then spy for rundll32.exe termination and finaly reboot the computer.

My question is how can I spy for rundll32.exe termination using VBScript 5.1 + Wsh 1.1 + NTResKit.

I found the WScript.Shell Exec method but this doesn't work with VBScript 5.1.

Anyone can help me ?

Thanks in advance
 
I found a solution using NT ResKit tool (Tlist).

ret = objShell.Run("tlist.exe | find /I /C /N ""rundll32.exe""")

If ret = 0 Then rundll32 is in execution
Else no rundll32 instance.
 
I have tried using your code with TASKLIST a winxp command, similar to tlist, however it always returns 0 regardless of the result.

rcode = wsh.run("Tasklist /FI ""Imagename eq notepad.exe"" /FI ""STATUS eq running""")

rcode always equals 0, anythoughts, should i be setting anything else to get the correct RC I am sure the RC is coming from wsh.run and not the tasklist command ie tasklist is running successfully.

Steve
 
I have also tried TLIST, but results are not good, always responds 1 even if task is not running??

Steve
 
I have fixed this by running cmd /P /C tlist etc and then writing it out to a file and then reading result from the file and it works.
 
As a precision :

The result of objShell.Run("tlist.exe | find /I /C /N ""rundll32.exe""") depends of the result of the find command. The result of the find command is located into %errorlevel% env. variable.

If the process exists then the find command return 0, else it returns 1.

Ex : find "autoexec.bat" c:\ => echo %errorlevel% => 0
find "jsfjkdhfhj" c:\ => echo %errorlevel% => 1

That's why our codes are different. And the result you expect is different mine.

I do not prefer using a file rather than a pipe because you lose more CPU Cycles using a file.

Hope I were helpfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top