Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Run an EXE and wait
Message
From
16/04/2019 10:29:42
 
 
To
15/04/2019 10:47:30
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01667388
Message ID:
01668113
Views:
80
>>I need to run an exe with a parameter passed to it. Tried to look into this AppRun API but can figure it out. What is the command to run the exe (CreateObject and then ?)
>>
>>[UPDATE] - I have a solution. Thanks.
>
>Parameters are just lined up after the executable, separated by spaces. Actually, for more complicated command lines I generate a batch file and run that - comes handy for debugging the command itself. Here's my line to zip files (where pretty much everything is prepared beforehand):
>
	PROCEDURE doZip
>		LOCAL lnWA, lcZipName, listfile, lcbatFile, logfile, lcPKZ, lcThere
>		IF EMPTY(THIS.FILES)
>			alert("No fresh files to zip")
>			RETURN
>		ENDIF
>		lnWA=SELECT()
>		IF NOT DIRECTORY("zips")
>			MD zips
>		ENDIF
>
>		lcZipName=THIS.zipname
>		listfile=FULLPATH(".\zip.lst")
>		STRTOFILE(THIS.FILES, listfile)
>		lcbatFile=FULLPATH(FORCEEXT(SYS(2015),"bat"))
>		logfile=FORCEEXT(lcbatFile,"log")
>		THIS.logfile=logfile
>		lcPKZ=FULLPATH("pkzip25.exe")
>
>		TEXT textmerge noshow to lcBat
>"<<lcPkz>>" -add=update -dire "<<lcZipName>>"  @"<<listfile>>" >"<<logfile>>"
>		ENDTEXT
>		lcThere=FULLPATH(".")
>		STRTOFILE(lcBat, lcbatFile)
>		LOCAL oprocess AS api_apprun OF PROCESS.vcx
>		oprocess=NEWOBJECT('api_apprun','process', '', lcbatFile, lcThere, 'HID')
>		oprocess.LaunchAppAndWait()
>		RELEASE oprocess
>		ERASE (lcbatFile)
>		SELECT (lnWA)
>		RETURN
>	ENDPROC
Thanks Dragan. I found a simple solution using Windows Scripting Host:
oShell = CREATEOBJECT('WScript.Shell')
oShell.Run( '"My Application Name.exe" MyParameter'  ,  ,  .T. )   &&  .T. = Wait for completion / .F. return immediately
.
In the End, we will remember not the words of our enemies, but the silence of our friends - Martin Luther King, Jr.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform