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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Terminate dos program with WSH

Status
Not open for further replies.

vmikeydet

Programmer
Oct 22, 2002
4
US
I'm using Visual FoxPro v7 and Windows script host shell in Windows NT 4.0 to open a DOS window, run a DOS based executable program, and then provide the user the ability to cancel the program and return to the FoxPro application. This is all being done from a FoxPro program. The DOS program can be canceled by issueing a control-C to the the DOS window. The problem I am having is that while the program is running in the DOS window and a control-c is sent by the script host, nothing happens. The program keeps running and I have to manually stop the program by hitting ctrl-c from the keyboard.

Here is the code I am running from my FoxPro program to do all this:

DECLARE Sleep IN Win32API;
integer dwDelay

oShell = CREATEOBJECT("WScript.Shell")
oShell.run("cmd /k cd d:\projects & iscst3.exe", 3)
IF oShell.AppActivate("C:\WINNT")
= Sleep(100)
oShell.SendKeys("^c")
oShell.SendKeys("EXIT~")
ENDIF

As I noted before, the ^c in the SendKeys method is not stopping the iscst3 program in the DOS window. Any help is appreciated.

Thanks.
 
The "()" is missing

oShell.SendKeys("^(c)")


-- AirCon --
 
You might also need to add Sleep() for each SendKeys

-- AirCon --
 
Thanks for the suggestion of using () around the c. I inserted them, but still no luck. The program contiuues to run in the command window until I manually issue a ^c. If no program is running in the command window the ^c appears there. For some reason the SendKeys method is not interrupting the running program.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top