Is there a command to close a running program

Discuss and share scripts and script files...
Huidong
Posts: 213
Joined: 18 May 2011 21:55

Re: Is there a command to close a running program

Post by Huidong »

@serendipity
I tried the above without wait(1000), the first command successfully terminated defraggler (GUI) while the current tab was in sandbox, but then the second command did not start at all, until I added wait in between! So there's the tradeoff between run's wait option, and open's independency of the current path! What do you think?

serendipity
Posts: 3360
Joined: 07 May 2007 18:14
Location: NJ/NY

Re: Is there a command to close a running program

Post by serendipity »

Huidong wrote:@serendipity
I tried the above without wait(1000), the first command successfully terminated defraggler (GUI) while the current tab was in sandbox, but then the second command did not start at all, until I added wait in between! So there's the tradeoff between run's wait option, and open's independency of the current path! What do you think?
Yes, that's the tradeoff. That's why I suggested wait here.
And you can shorten the first line to:
open """%ComSpec%"" /c tskill Defraggler";

Huidong
Posts: 213
Joined: 18 May 2011 21:55

Re: Is there a command to close a running program

Post by Huidong »

Rocks! For reference, I just went to http://en.wikipedia.org/wiki/ComSpec
Thanks!

serendipity
Posts: 3360
Joined: 07 May 2007 18:14
Location: NJ/NY

Re: Is there a command to close a running program

Post by serendipity »

Huidong wrote:Rocks! For reference, I just went to http://en.wikipedia.org/wiki/ComSpec
Thanks!
Also look at Help>Environmental variables

Huidong
Posts: 213
Joined: 18 May 2011 21:55

Re: Is there a command to close a running program

Post by Huidong »

Oh good reminder!
And here's an immediate benefit using open and %comspec%.
Compare

Code: Select all

"Run Registry Workshop as SYSTEM"
  open '"%comspec%" /c psexec -s -i "C:\Program Files\Registry Workshop\RegWorkshop.exe"';
with the orignial

Code: Select all

"Run Registry Workshop as SYSTEM"
  goto "%computer%", 1;
  run "cmd /c cd /d C:\Windows\System32\ & PsExec -s -i ""C:\Program Files\Registry Workshop\RegWorkshop.exe""";
  #520; //Go back
Both avoided being trapped in sandbox but the second is ugly.
Happy.

Post Reply