Good that everything works now.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: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.Code: Select all
"Run regedit as SYSTEM" run "cmd /k cd /d C:\Windows\System32\ & PsExec -s -i regedit"
But thanks very much, learning a lot of things.
Is there a command to close a running program
-
serendipity
- Posts: 3360
- Joined: 07 May 2007 18:14
- Location: NJ/NY
Re: Is there a command to close a running program
-
Huidong
- Posts: 213
- Joined: 18 May 2011 21:55
Re: Is there a command to close a running program
Again when the current tab is, say D:\Sandbox\...\..., and I click a button to run the following
I get the following
But defraggler can be killed if the current tab is say D:\download.
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';To see the attached files, you need to log into the forum.
-
Huidong
- Posts: 213
- Joined: 18 May 2011 21:55
Re: Is there a command to close a running program
No, not everything is working!! But maybe tomorrow. Are you in US? If so, sorry to bother you so much. Good night.
-
serendipity
- Posts: 3360
- Joined: 07 May 2007 18:14
- Location: NJ/NY
Re: Is there a command to close a running program
And you are using C:\Windows\System32\ because it is not sandboxed right?Huidong wrote:Again when the current tab is, say D:\Sandbox\...\..., and I click a button to run the followingI get the following But defraggler can be killed if the current tab is say D:\download.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';
Maybe try using a non-system folder instead of system32.
And use cmd /c
-
Huidong
- Posts: 213
- Joined: 18 May 2011 21:55
Re: Is there a command to close a running program
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.
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.
-
Huidong
- Posts: 213
- Joined: 18 May 2011 21:55
Re: Is there a command to close a running program
Alright, one working escape from sandbox is the following
I have the "Computer" tab always open.
If there exists a better way to escape sandbox, please let me know.
Thank you all!
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 runIf there exists a better way to escape sandbox, please let me know.
Thank you all!
-
serendipity
- Posts: 3360
- Joined: 07 May 2007 18:14
- Location: NJ/NY
Re: Is there a command to close a running program
You never replied if this worked:Huidong wrote:Alright, one working escape from sandbox is the followingI have the "Computer" tab always open.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
If there exists a better way to escape sandbox, please let me know.
Thank you all!
run (TSKILL defraggler);
-
Huidong
- Posts: 213
- Joined: 18 May 2011 21:55
Re: Is there a command to close a running program
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.You never replied if this worked:
run (TSKILL defraggler);
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.
-
serendipity
- Posts: 3360
- Joined: 07 May 2007 18:14
- Location: NJ/NY
Re: Is there a command to close a running program
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.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.
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";
-
Huidong
- Posts: 213
- Joined: 18 May 2011 21:55
Re: Is there a command to close a running program
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?
-
serendipity
- Posts: 3360
- Joined: 07 May 2007 18:14
- Location: NJ/NY
Re: Is there a command to close a running program
If you use Open?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?
open "d:\KillDF.bat";
-
Huidong
- Posts: 213
- Joined: 18 May 2011 21:55
Re: Is there a command to close a running program
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!
Thank you very much, learned writefile and batch file!
-
serendipity
- Posts: 3360
- Joined: 07 May 2007 18:14
- Location: NJ/NY
Re: Is there a command to close a running program
Good it works.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!
And as for wait option, try this undocumented command:
//Wait 1 second
wait (1000);
-
Huidong
- Posts: 213
- Joined: 18 May 2011 21:55
Re: Is there a command to close a running program
I was looking for wait() once!
Is time its only argument?
Is time its only argument?
-
Huidong
- Posts: 213
- Joined: 18 May 2011 21:55
Re: Is there a command to close a running program
One more question, why can't I use open to call cmd, e.g.
Is that because open does not recognize cmd without a full path?
[edit 1]
Sorry I should have tried it myself, the following works
[edit 2]
Now the following works as a whole for defraggler
Code: Select all
open "cmd /c cd /d C:\ & tskill defraggler";[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";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';
XYplorer Beta Club