1.

Solve : [Sloved] Wait for an EXE to be launched and used?

Answer»

While playing around as theoretical publisher, I have several times been stuck in this situation, I need some kind of script that does this:

  • Launch Installer.EXE (Setup Wizard)
  • Wait for it to close after install finishes
  • Launch UPDATE.EXE (Update Wizard)

At this moment I have a some "half" working batch file:
Code: [Select]echo off
seccd.exe "Installer.EXE"
UPDATE.EXE
exit
seccd.exe is a tool that checks if itself is stored on a harddrive or CD, if it's not on a CD it will not run "Installer.EXE", it will just show you "You must install this software from the original CD!.  Process terminated"

How do I get it working?

PS. (As in my sig.)
Sometimes, C++, Batch, PAWN, HTML and GML is not enough Quote from: Ryder17z on May 22, 2009, 02:56:02 PM
While playing around as theoretical publisher, I have several times been stuck in this situation, I need some kind of script that does this:

  • Launch Installer.EXE (Setup Wizard)
  • Wait for it to close after install finishes
  • Launch UPDATE.EXE (Update Wizard)

At this moment I have a some "half" working batch file:
Code: [Select]echo off
seccd.exe "Installer.EXE"
UPDATE.EXE
exit
seccd.exe is a tool that checks if itself is stored on a harddrive or CD, if it's not on a CD it will not run "Installer.EXE", it will just show you "You must install this software from the original CD!.  Process terminated"

How do I get it working?

PS. (As in my sig.)
Sometimes, C++, Batch, PAWN, HTML and GML is not enough
Run "CMD /k help start" for more information.Oops, I forgot something:

Installer.exe installs main components, then executes another EXE that contains current updates

I found something, might useful, in VB:
Code: [Select]Set objWMI = GetObject("winmgmts:\\.\root\cimv2")

strStopQuery = "SELECT * FROM __InstanceDeletionEvent WITHIN 1 WHERE TargetInstance ISA 'Win32_Process' " &_
"AND TargetInstance.Name = 'setup\setup.exe.exe'"
strStartQuery = "SELECT * FROM __InstanceCreationEvent WITHIN 1 WHERE TargetInstance ISA 'Win32_Process' " &_
"AND TargetInstance.Name = 'update.exe.exe'"

' Catch process when it starts
' Or alternatively you check if a process is running rather than catching it when it starts
' by querying Win32_Process
Set objEventSource = objWMI.ExecNotificationQuery(strStartQuery) ' Event query
Set objEventObject = objEventSource.NextEvent() ' Wait for the event to occur
WScript.Echo("Process has started, waiting...")

' Catch process when it stops
Set objEventSource = objWMI.ExecNotificationQuery(strStopQuery) ' Event query
Set objEventObject = objEventSource.NextEvent() ' Wait for the event to occur
Wscript.Echo("Process stopped, do stuff")But it doesn't want to work with the path's usedthis is easy, but i am not in the mood to tell you. good luck in googling...  Doesn't seem so easy, I haven't found a way to do it, TASKLIST gives me ERRORS about wrong syntax, VB does something that is equal to zero and so on

Do I need to spend another week, trying to find a sulotion?have you read the "start /?" output? namely the portion about the /WAIT switch?


Also in the VBSCRIPT why are you using "setup\setup.exe.exe" and "update.exe.exe" instead of just .exe? why two ".exe"s?Typos, BC

And the wait parameter won't work since it only waits for the program it started, but as mentioned: Installer.EXE runs, then if properly used, it launches a tool to check if it was installed properly and if so, install current updates by starting another EXE

After that tool is launched, only then, the batch file should run UPDATE.EXE, because it's highly unlikely you want to install updates for a software that isn't even installed, or am I missing something ?


I hope I have explained enough now..

EDIT:
The first EXE updater contains what we would call "Official" and the second installs "Unofficial" updates Quote from: Ryder17z on May 23, 2009, 12:19:10 PM
Typos, BC

And the wait parameter won't work since it only waits for the program it started, but as mentioned: Installer.EXE runs, then if properly used, it launches a tool to check if it was installed properly and if so, install current updates by starting another EXE

After that tool is launched, only then, the batch file should run UPDATE.EXE, because it's highly unlikely you want to install updates for a software that isn't even installed, or am I missing something ?


I hope I have explained enough now..

EDIT:
The first EXE updater contains what we would call "Official" and the second installs "Unofficial" updates
Start /wait will wait for the program to TERMINATE before continuing on with the batch script.No, it doesn't, I have checked it on 3 PC's, all WinXP SP3

Sure, it waits, but not for the correct program to close Quote from: Ryder17z on May 25, 2009, 06:24:29 AM
No, it doesn't, I have checked it on 3 PC's, all WinXP SP3

Sure, it waits, but not for the correct program to close
It doesn't wait for GUI APPS to close...just read that now.I found a way to do it, with some help from PrcView and one batch file


Sample used to see if it worked: Code: [Select]echo off
:BEGIN
pv.exe notepad.exe >nul
if ERRORLEVEL 1 goto Process_NotFound
:Process_Found
echo Process notepad.exe is running
goto BEGIN
:Process_NotFound
echo Process notepad.exe is not running
pause
exit
I'm gonna change it, so it won't check every 1/50 seconds (or whatever the processing SPEED is)


So, I guess, you should NEVER give up something, not even the slightest possible (as long as someone can support it)


Discussion

No Comment Found