Trust No Program
Reply to topic
Multiple "%SANDBOX%" in "Delete Command"
lwc


Joined: 19 Dec 2006
Posts: 299
Reply with quote
If I try to use it twice or more (using cmd /c command "%SANDBOX%" && another command "%SANDBOX%"), then it fails and the error prompt adds an ID to the folder ("e.g. Delete command failed: "first command. c:\sandbox\_Delete_TempBox_3423dfsafjdksl && second command c:\sandbox\_Delete_TempBox_3423dfsafjdksl").

It's not, I repeat - not, because of the "&&" because the same command runs fine if it looks like:
cmd /c command "%SANDBOX%" && another command "c:\sandbox\TempBox"
(that is, the second time I need "%SANDBOX%" I write it manually).
View user's profileSend private message
tzuk


Joined: 22 Jun 2004
Posts: 14999
Reply with quote
Your quote shows the %SANDBOX% was replaced twice correctly. That's the end of the story as far as I'm concerned. The DeleteCommand isn't a command processor, it just runs one program. So the program you're running is cmd.exe and you pass &&s and you see that cmd.exe isn't handling the &&s correctly. Ok, but why are you complaining here, implying that DeleteCommand is broken? Just use a batch file and move on.

_________________
tzuk
View user's profileSend private message
lwc


Joined: 19 Dec 2006
Posts: 299
Reply with quote
Using "&&" was just an example. Problems occur whenever you use the word "%SANDBOX%" more than once (e.g. "%ComSpec%" /c copy "%SANDBOX%\RegHive" "%SANDBOX%\foobar.txt".

Hmm, I think I understand now. Sandboxie renames the sandbox before launching the "Delete Command". Therefore, "%SANDBOX%" actually stands for the renamed (temporary) name and not the original name. So basically what I would have wanted is:
"%ComSpec%" /c copy "%SANDBOX%\RegHive" "%ORIGINAL_NAME_OF_SANDBOX%\foobar.txt".
Alas, there's no such thing as "%ORIGINAL_NAME_OF_SANDBOX%".
View user's profileSend private message
tzuk


Joined: 22 Jun 2004
Posts: 14999
Reply with quote
One more thing to take into account is that you get the "Delete Command failed: xxxxx" message box if the command launched returns a non-zero return code. I'm not adding %ORIGINAL_NAME_OF_SANDBOX%; I'm not even sure that I agree with your use of DeleteCommand to populate the sandbox.

Again I say: Use a batch file. Here is an exercise for you to try in a command prompt window:

Code:

C>set SANDBOX=__Delete_DefaultBox_01C87E1832BF7182
C>for /F " tokens=2 delims=_ " %A IN ("%SANDBOX%") do set BOXNAME=%A
C>echo %BOXNAME%
DefaultBox


See, you can manufacture your own %ORIGINAL_NAME_OF_SANDBOX% without my help.

(If you're going to put that in a batch file, you may need to change the %A's into %%A's. I think I remember something about batch files requirement for two percent marks there.)
View user's profileSend private message
lwc


Joined: 19 Dec 2006
Posts: 299
Reply with quote
Quote:
I'm not even sure that I agree with your use of DeleteCommand to populate the sandbox.

That's because I haven't found an external equivalent for "Auto Exec"
(that could run CMD in order to duplicate sandboxes).

Anyway, your commands work for "__Delete_DefaultBox_01C87E1832BF7182" but not for what what Sandbox actually is: "c:\sandbox\%username%\__Delete_DefaultBox_01C87E1832BF7182" - do you know how to make it work then? Thanks.


Last edited by lwc on Tue Mar 04, 2008 9:07 pm; edited 1 time in total
View user's profileSend private message
tzuk


Joined: 22 Jun 2004
Posts: 14999
Reply with quote
Come on now ... I was only making the point that you can take the %SANDBOX% and parse it anyway you want, and you don't need me to make changes to Sandboxie for that. I didn't mean that I was going to do it for you.

Nevertheless I'm going to assume that this is the last question on this issue, so I will extend my example:

Code:

set SANDBOXPATH=c:\sandbox\%username%\__Delete_DefaultBox_01C87E1832BF7182
for /F " tokens=4 delims=\ " %A IN ("%SANDBOXPATH%") do set SANDBOX=%A
for /F " tokens=2 delims=_ " %A IN ("%SANDBOX%") do set BOXNAME=%A
echo %BOXNAME%


%BOXNAME% will be DefaultBox.
View user's profileSend private message
lwc


Joined: 19 Dec 2006
Posts: 299
Reply with quote
Okay, there's no more need for you to reply to this topic anymore, but I've just discovered tokens=3 does the job too.

So I've updated the duplicating sandboxes' topic accordingly.
View user's profileSend private message
Multiple "%SANDBOX%" in "Delete Command"
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT  
Page 1 of 1  

Use the RSS feed to watch this topic for replies
  
  
 Reply to topic  

Sandboxie is Copyright © 2004-2012 by Sandboxie Holdings LLC.  All rights reserved.
Sandboxie.com | Contact Author
This site has been viewed 207,854,931 times since June 2004