Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

!¦RUN command 3

Status
Not open for further replies.

ChrisRChamberlain

Programmer
Mar 23, 2000
3,392
GB
I would like to substitute RUN /N2 *.exe with a suitable Windows API call.

The programs concerned are PkZip25.exe, Cabarc.exe and Extract.exe, all of which show a DOS window during execution, unless the /N2 argument is used.

TIA

Chris

[sig][/sig]
 
[tt] does this help

*procedure RunExe
lparameters pcExeName, pcParameters
* first parameter required, other - optional
* returns - .T. when successful, .F. when failed

local lcAppRunString
if parameters() > 1
m.lcAppRunString = ' ' + pcParameters
else
m.lcAppRunString = ''
endif
m.lcAppRunString = allt(m.pcExeName) + m.lcAppRunString
*
&& Function declaration
declare integer WinExec in kernel32 string lpCmdLine, integer uCmdShow
*
&& try run exe

if WinExec(m.lcAppRunString, 1) > 31
&& running exe successfully
return .t.
endif

return .f.
endproc
[/tt]
[sig]<p>David W. Grewe<br><a href=mailto:Dave@internationalbid.net>Dave@internationalbid.net</a><br><a href= > </a><br> [/sig]
 
Neato Torpeado!

You should consider putting that in the FAQ!

[sig]<p> Pete<br><a href=mailto:blindpete@mail.com>blindpete@mail.com</a><br><a href= > </a><br>What your mother told you is true! You will go blind! (from moonshine anyway)[/sig]
 
David

Thanks for your response.

The code you suggested is similar to that I use for normal API calls to run executables - the problem in this case is that the programs need to be run minimised, otherwise the user has sight of the DOS window, which is an untidy distraction.

Chris [sig][/sig]
 
Sorry, I thought /N7 was miminized [sig]<p>David W. Grewe<br><a href=mailto:Dave@internationalbid.net>Dave@internationalbid.net</a><br><a href= > </a><br> [/sig]
 
Chris,

You could change FOXRUN.PIF to be minimized. VFP uses that PIF for all DOS apps run with RUN. I did that for the DOS PKware tools like PKZIP and ZIP2EXE. [sig]<p> Pete<br><a href=mailto:blindpete@mail.com>blindpete@mail.com</a><br><a href= > </a><br>What your mother told you is true! You will go blind! (from moonshine anyway)[/sig]
 
Pete

Thanks for the idea but it still means using the RUN command.

The RUN command actually works fine but I would like to substitute it with a suitable API call.

On the other hand If it ain't broke, don't fix it as my old granny used to say.

Chris [sig][/sig]
 
dgrewe - put this to FAQ. This is not a first thread about RUN command. [sig]<p>Vlad Grynchyshyn<br><a href=mailto:vgryn@softserve.lviv.ua>vgryn@softserve.lviv.ua</a><br>[/sig]
 
OK, If you say So but I rewote it
[tt]
lparameters pcExeName, pcParameters
* first parameter required, other - optional
local lcRunString
m.lcRunString = allt(m.pcExeName) + iif(parameters() > 1 , + &quot; &quot; + m.pcParameters , &quot;&quot;)
declare integer WinExec in kernel32 string lpCmdLine, integer uCmdShow
return iif(WinExec(m.lcRunString, 1) > 31 , .t. , .f.)
endproc
[/tt] [sig]<p>David W. Grewe<br><a href=mailto:Dave@internationalbid.net>Dave@internationalbid.net</a><br><a href= > </a><br> [/sig]
 
Chris, FWIW, the second parameter of the WinExec API function is the window state:

0 = Hide
1 = Normal
3 = Maximized
6 = Minimized

There are others, but these are the only ones I can remember off hand. [sig]<p>Jon Hawkins<br><a href=mailto: jonscott8@yahoo.com> jonscott8@yahoo.com</a><br><a href= > </a><br>Carpe Diem! - Seize the Day![/sig]
 
Jon

Bang on target! Thank you.

The other advantage is that you can run these programs hidden and thus prevent, (other than hitting CTRL+ALT+DEL), a user from interfering with their execution.

Chris [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top