Re: Is there any way to start (and later quit) an EXE file.

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Steve,

Since you're running Windows XP, you can use WMI which I think is simpler
than setting up to use Windows API. Of course, you might open the VBE and
check under 'Tools > References' to see if you might not have the ability to
control some of the objects associated with VNC.exe.

Anyway, the subroutines below should get you going. Paste the publicly
declared variable as well as the two subroutines into a module after opening
VBE (Alt plus F11). Since I didn't have VNC.exe to test on, the subroutine
is set to launch a new notepad.exe process when you run the subroutine,
LaunchApp(), and then terminate that process when you run QuitApp(). After
you test with notepad, go into the LaunchApp() subroutine and edit the line
beginning with "strApp =" to point to your exe rather than notepad. Since
VNC.exe probably isn't in your system path, you will want to include the
full path statement along with the file name.

_________________________________________

Public intProcessID As Integer

Sub LaunchApp()

strApp = "Notepad.exe"

Set objProcess = GetObject("winmgmts:root\cimv2:Win32_Process")
errReturn = objProcess.Create(strApp, Null, Null, intProcessID)
Set objProcess = Nothing

End Sub


Sub QuitApp()
Dim objWMIService
Dim colProcessList

Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colProcessList = objWMIService.ExecQuery _
("Select * from Win32_Process Where ProcessID = " & intProcessID & "")
For Each objProcess In colProcessList
objProcess.Terminate
Next
End Sub

_________________________________________

Steve



"Steve" <Steve@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:2327507A-FA35-4B51-8F67-62C978F63198@xxxxxxxxxxxxxxxx
Thanks Steve
We are using WinXP. The reason I would like to quit at some point is to
regain complete control of XP and lose barcode scanner control. We then
use
excel to load the data into a database that cannot at this point be
controlled by the Scanner.
We are using VNC.exe as the executable, which puts the top left corner of
excel on the scanner screen.


"Steve Yandl" wrote:

Steve,

You can use the Shell function to launch an executable file but you don't
retain control of it which means you can't shut it down from within your
VBA
code. Typically, you would use the Windows API to shut down the
application
which is somewhat cumbersome but not impossible.

If you're not using this on any systems with Win98 or earlier, there is
an
option using WMI. Basically, you launch the application and capture the
process ID value at the same time and then use a second WMI routine to
kill
the process with that PID. Let us know if this situation applies.

Steve Yandl




"Steve" <Steve@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:A6BD99EB-5AB4-469D-A01F-F02D2F8D27C6@xxxxxxxxxxxxxxxx
I am trying to start the following program when I activate a
page."C:\Program
Files\RealVNC\vncviewer.exe" -listen

The purpose is to use a barcode scanner and load data into excel. The
above
program has to be resident in the Tray for the scanner to load data
into a
data page. Later I would like to unload or quit the EXE file to let
excel
get
control back. Any thoughts would be greatly appreciated.
Thanks
Steve





.



Relevant Pages

  • Re: Is there any way to start (and later quit) an EXE file.
    ... the QuitApp subroutine so that it will terminate any process named "VNC.exe" ... Is there also a way to avoid the first macro trying to load the EXE a ... regain complete control of XP and lose barcode scanner control. ... You can use the Shell function to launch an executable file but you ...
    (microsoft.public.excel.misc)
  • Re: Is there any way to start (and later quit) an EXE file.
    ... Fantastic Steve. ... regain complete control of XP and lose barcode scanner control. ... You can use the Shell function to launch an executable file but you don't ...
    (microsoft.public.excel.misc)
  • Venus Express team in launch countdown (Forwarded)
    ... The excitement at ESOC and particularly in the Main Control Room is palpable as launch preparations get under way. ... overseeing the 'B' section of the MCT conduct a series of live pre-flight checks, which included confirming main and alternative data communications with the initial ground control stations for Venus Express, located in Australia, California and Kourou, French Guiana. ...
    (sci.astro)
  • Re: An Agena FOBS?
    ...  > Who said command and control? ... coordinated> EVERY launch. ...  > Are you saying NORAD couldn't talk to commanders of Corona? ... the launcher on command. ...
    (sci.space.history)
  • Re: Winch Launch Safety Study
    ... I agree that the first part of a launch that might involve excessive ... control way too fast for any radio transmission to help. ... as a winch, and thus the chances of over rotation with the stick full ... "Drehzahlregelung" (OK better translation would be RPM controlled). ...
    (rec.aviation.soaring)