Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: [Sloved] Wait for an EXE to be launched and used  (Read 6604 times)

0 Members and 1 Guest are viewing this topic.

Ryder17z

    Topic Starter


    Intermediate
  • Thanked: 2
    • Yes
  • Computer: Specs
  • Experience: Experienced
  • OS: Windows 10
[Sloved] Wait for an EXE to be launched and used
« 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 ::)
« Last Edit: May 30, 2009, 12:52:12 PM by Ryder17z »
The cake is a lie...

Helpmeh



    Guru

  • Roar.
  • Thanked: 123
    • Yes
    • Yes
  • Computer: Specs
  • Experience: Familiar
  • OS: Windows 8
Re: Wait for an EXE to be launched and used
« Reply #1 on: May 22, 2009, 03:36:53 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.
Where's MagicSpeed?
Quote from: 'matt'
He's playing a game called IRL. Great graphics, *censored* gameplay.

Ryder17z

    Topic Starter


    Intermediate
  • Thanked: 2
    • Yes
  • Computer: Specs
  • Experience: Experienced
  • OS: Windows 10
Re: Wait for an EXE to be launched and used
« Reply #2 on: May 23, 2009, 05:29:23 AM »
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 used
The cake is a lie...

Reno



    Hopeful
  • Thanked: 32
    Re: Wait for an EXE to be launched and used
    « Reply #3 on: May 23, 2009, 06:08:52 AM »
    this is easy, but i am not in the mood to tell you. good luck in googling...  ::)

    Ryder17z

      Topic Starter


      Intermediate
    • Thanked: 2
      • Yes
    • Computer: Specs
    • Experience: Experienced
    • OS: Windows 10
    Re: Wait for an EXE to be launched and used
    « Reply #4 on: May 23, 2009, 07:29:44 AM »
    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?
    The cake is a lie...

    BC_Programmer


      Mastermind
    • Typing is no substitute for thinking.
    • Thanked: 1140
      • Yes
      • Yes
      • BC-Programming.com
    • Certifications: List
    • Computer: Specs
    • Experience: Beginner
    • OS: Windows 11
    Re: Wait for an EXE to be launched and used
    « Reply #5 on: May 23, 2009, 09:50:23 AM »
    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?
    I was trying to dereference Null Pointers before it was cool.

    Ryder17z

      Topic Starter


      Intermediate
    • Thanked: 2
      • Yes
    • Computer: Specs
    • Experience: Experienced
    • OS: Windows 10
    Re: Wait for an EXE to be launched and used
    « Reply #6 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
    The cake is a lie...

    Helpmeh



      Guru

    • Roar.
    • Thanked: 123
      • Yes
      • Yes
    • Computer: Specs
    • Experience: Familiar
    • OS: Windows 8
    Re: Wait for an EXE to be launched and used
    « Reply #7 on: May 24, 2009, 10:12:10 AM »
    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.
    Where's MagicSpeed?
    Quote from: 'matt'
    He's playing a game called IRL. Great graphics, *censored* gameplay.

    Ryder17z

      Topic Starter


      Intermediate
    • Thanked: 2
      • Yes
    • Computer: Specs
    • Experience: Experienced
    • OS: Windows 10
    Re: Wait for an EXE to be launched and used
    « Reply #8 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
    The cake is a lie...

    Helpmeh



      Guru

    • Roar.
    • Thanked: 123
      • Yes
      • Yes
    • Computer: Specs
    • Experience: Familiar
    • OS: Windows 8
    Re: Wait for an EXE to be launched and used
    « Reply #9 on: May 25, 2009, 01:44:59 PM »
    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.
    Where's MagicSpeed?
    Quote from: 'matt'
    He's playing a game called IRL. Great graphics, *censored* gameplay.

    Ryder17z

      Topic Starter


      Intermediate
    • Thanked: 2
      • Yes
    • Computer: Specs
    • Experience: Experienced
    • OS: Windows 10
    Re: Wait for an EXE to be launched and used
    « Reply #10 on: May 30, 2009, 12:51:39 PM »
    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) ::)
    The cake is a lie...