Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Calling a exe from within VFP with parameters
Message
From
17/02/2017 16:20:15
 
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012 R2
Network:
Windows Server 2012 R2
Database:
Visual FoxPro
Application:
Desktop
Virtual environment:
VMWare
Miscellaneous
Thread ID:
01648061
Message ID:
01648106
Views:
74
Likes (1)
On Lutz Scheffer pointing this is a simple code how to use the ed Rauh process class
*using ED RAUH api_run class
*can download the zip from UT at :
 https://www.levelextreme.com/Report.aspx?Report=11&Numero=9477

 

oo=Newobject("api_apprun","process.vcx")

With oo
	.icCommandline="notepad.exe"
	.icLaunchDir=Addbs(Justpath(Sys(16,1)))
	.icWindowMode=''
	.launchApp()

	Inkey(2)  &&wait 2sec
	If Messagebox("Want to terminate "+.icCommandline +" ?",4+64+4096)=6
		.killProc(.icCommandline)
		If  !Empty(.icErrorMessage)
			Messagebox("ErrorMessage="+.icErrorMessage)
		Endi
	Endi

	Messagebox( .icCommandline+"terminated with return code="+Trans(.checkprocessexitcode()))
Endwith
can also use the class browser and convert it as prg and use : set procedure to api_apprun additive....

to terminate any running process (and return an exitcode) can also use this scripting methods:
run/n notepad
run/n notepad
inke(1)

LOCAL loWMI, lcQuery, loResult, loProcess
loWMI = GetObject("winmgmts://")
lcQuery= "select * from win32_process where name='notepad.exe'"  &&here the exe name application to kill
loResult = loWMI.ExecQuery(lcQuery)
local x
FOR EACH loProcess IN loResult
	x=loProcess.Terminate(0)
messagebox("exitcode="+trans(x),0+32+4096,'',1000)
NEXT
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform