Page 3 of 4
Re: Is there a command to close a running program
Posted: 21 May 2011 11:33
by serendipity
Huidong wrote:Really good news!
run "cmd /K cd /d c:\ & TSKILL defraggler";
did not work, but I did use your command to do sth very handy:
Code: Select all
"Run regedit as SYSTEM"
run "cmd /k cd /d C:\Windows\System32\ & PsExec -s -i regedit"
Back to the issue, when I run tskill when the current tab is in sandbox, the cmd did open in C:\, but it reports that end process failed because access is denied. Moreover, even when the current tab is out of sandbox, in which case tskill can kill defraggler, but the cmd window remains open so the next command (calling df.exe) can not start. This did not happen using /c.
But thanks very much, learning a lot of things.
Good that everything works now.
Re: Is there a command to close a running program
Posted: 21 May 2011 11:34
by Huidong
Again when the current tab is, say D:\Sandbox\...\..., and I click a button to run the following
Code: Select all
"Defrag selected (Recursive)"
run "cmd /k cd /d C:\Windows\System32\ & tskill defraggler", , 1;
open '"D:\Portable\Defraggler\df.exe" <selitems> /S';
I get the following
Administrator_ C__Windows_system32_cmd.exe_Microsoft_ Windows_ Operating System (Windows Command Processor) [cmd]_2011-05-21.png
But defraggler can be killed if the current tab is say D:\download.
Re: Is there a command to close a running program
Posted: 21 May 2011 11:35
by Huidong
No, not everything is working!! But maybe tomorrow. Are you in US? If so, sorry to bother you so much. Good night.
Re: Is there a command to close a running program
Posted: 21 May 2011 11:45
by serendipity
Huidong wrote:Again when the current tab is, say D:\Sandbox\...\..., and I click a button to run the following
Code: Select all
"Defrag selected (Recursive)"
run "cmd /k cd /d C:\Windows\System32\ & tskill defraggler", , 1;
open '"D:\Portable\Defraggler\df.exe" <selitems> /S';
I get the following
Administrator_ C__Windows_system32_cmd.exe_Microsoft_ Windows_ Operating System (Windows Command Processor) [cmd]_2011-05-21.png
But defraggler can be killed if the current tab is say D:\download.
And you are using C:\Windows\System32\ because it is not sandboxed right?
Maybe try using a non-system folder instead of system32.
And use cmd /c
Re: Is there a command to close a running program
Posted: 21 May 2011 18:50
by Huidong
I tried using cd /d D:\download\, but the same problem, access denied...
Oh, I noticed that cmd was started within the sandbox, when the current tab is in that sandbox! Even though I used cd /d ...
as you suggested.
Re: Is there a command to close a running program
Posted: 21 May 2011 21:10
by Huidong
Alright, one working escape from sandbox is the following
Code: Select all
"Defrag selected (Recursive)"
goto "%computer%", 1;
run "cmd /c cd /d C:\ & tskill defraggler";
#520; //Go back
open '"D:\Portable\Defraggler\df.exe" <selitems> /S'; //Cannot use run
I have the "Computer" tab always open.
If there exists a better way to escape sandbox, please let me know.
Thank you all!
Re: Is there a command to close a running program
Posted: 22 May 2011 08:04
by serendipity
Huidong wrote:Alright, one working escape from sandbox is the following
Code: Select all
"Defrag selected (Recursive)"
goto "%computer%", 1;
run "cmd /c cd /d C:\ & tskill defraggler";
#520; //Go back
open '"D:\Portable\Defraggler\df.exe" <selitems> /S'; //Cannot use run
I have the "Computer" tab always open.
If there exists a better way to escape sandbox, please let me know.
Thank you all!
You never replied if this worked:
run (TSKILL defraggler);
Re: Is there a command to close a running program
Posted: 22 May 2011 09:18
by Huidong
You never replied if this worked:
run (TSKILL defraggler);
I'm sorry, serendipity, I thought I already replied implicitly: I said it wasn't a matter of cmd tskill or sysinternals pskill's capability of killing defraggler, both are capable, the failure only occurred when I run the command
while the current tab is in a sandbox, in which case either cmd or pskill is trapped in that sandbox, hence neither can terminate any process from inside the sandbox. So I used goto to switch to a tab outside sandbox before calling cmd.
However, I did ask if there exist a better way to run cmd that is independent of the location of the current tab.
Thank you.
Re: Is there a command to close a running program
Posted: 22 May 2011 10:53
by serendipity
Huidong wrote:However, I did ask if there exist a better way to run cmd that is independent of the location of the current tab.
Thank you.
You could create a batch file in another location and run it from there (and optionally delete it). That way you don't have to go to another location manually and run command.
See if this method works.
Code: Select all
//(1) Write KillDF.bat file
writefile ("d:\KillDF.bat", "@echo off<crlf>TSKILL Defraggler");
//(2) Run batch file
run """d:\KillDF.bat""",, 1;
//(3) Delete KillDF.bat file
delete 0, 0, "d:\KillDF.bat";
//(4) Run df.exe
run """D:\Portable\Defraggler\df.exe"" <selitems> /S";
or you can create batch file once i.e. step (1) and use steps (2) and (4) eachtime you want to defrag.
Re: Is there a command to close a running program
Posted: 22 May 2011 18:16
by Huidong
Thanks! I tried out, steps 1, 3, 4 are working, but in step 2 cmd is still trapped in sandbox, hence in step 4, df.exe is also trapped in sandbox, not working. Really strange, so is this a limitation of "run" or "cmd" that it must take into consideration the current path? In this case, since the batch file is not in the sandbox, it seems that it's not cmd, but instead run, that gets fed with the current tab location. What do you think?
Re: Is there a command to close a running program
Posted: 22 May 2011 18:45
by serendipity
Huidong wrote:Thanks! I tried out, steps 1, 3, 4 are working, but in step 2 cmd is still trapped in sandbox, hence in step 4, df.exe is also trapped in sandbox, not working. Really strange, so is this a limitation of "run" or "cmd" that it must take into consideration the current path? In this case, since the batch file is not in the sandbox, it seems that it's not cmd, but instead run, that gets fed with the current tab location. What do you think?
If you use Open?
open "d:\KillDF.bat";
Re: Is there a command to close a running program
Posted: 22 May 2011 18:54
by Huidong
That's the solution! Open does not care about the current path it seems, and I have to use open also for step 4, otherwise df.exe will still be run inside the sandbox, while open won't do that! So from now on, I'm going to use open whenever possible except I need the wait option.
Thank you very much, learned writefile and batch file!
Re: Is there a command to close a running program
Posted: 22 May 2011 19:02
by serendipity
Huidong wrote:That's the solution! Open does not care about the current path it seems, and I have to use open also for step 4, otherwise df.exe will still be run inside the sandbox, while open won't do that! So from now on, I'm going to use open whenever possible except I need the wait option.
Thank you very much, learned writefile and batch file!
Good it works.
And as for wait option, try this undocumented command:
//Wait 1 second
wait (1000);
Re: Is there a command to close a running program
Posted: 22 May 2011 19:06
by Huidong
I was looking for wait() once!
Is time its only argument?
Re: Is there a command to close a running program
Posted: 22 May 2011 19:10
by Huidong
One more question, why can't I use open to call cmd, e.g.
Code: Select all
open "cmd /c cd /d C:\ & tskill defraggler";
Is that because open does not recognize cmd without a full path?
[edit 1]
Sorry I should have tried it myself, the following works
Code: Select all
open """c:\windows\system32\cmd.exe"" /c cd /d C:\ & tskill defraggler";
[edit 2]
Now the following works as a whole for defraggler
Code: Select all
"Defrag selected (Recursive)"
open '"C:\Windows\System32\cmd.exe" /c cd /d C:\ & tskill defraggler';
wait(1000);
open '"D:\Portable\Defraggler\df.exe" <selitems> /S';