Trust No Program
This topic is locked: you cannot edit posts or make replies.
[.06] Terminate programs after exiting from a script
Max100


Joined: 20 Oct 2009
Posts: 159
Reply with quote
I created this shortcut on desktop:

Code:
"C:\Program Files\Sandboxie\Start.exe" /box:Trash /hide_window "C:\svabi\program\start.bat"


And this is the content of start.bat:

Code:
sc start "Micro Focus License Manager"
start /wait ca-start.exe


1) How can I include /terminate_all command in this script to terminate all programs in all sandboxes after that I exit from this executable?

2) /terminate_all command terminates also running services? Because I'd like to stop all running services after exiting from the executable.

Thank you.
View user's profileSend private message
tzuk


Joined: 22 Jun 2004
Posts: 15004
Reply with quote
You can use the parameter /wait in Start.exe, this will cause Start.exe to suspend until the program ends.

You would need to change your desktop shortcut so it starts a batch script that runs outside the sandbox:

NewScript.bat:
Code:
"C:\Program Files\Sandboxie\Start.exe" /wait /box:Trash /hide_window "C:\svabi\program\start.bat"
"C:\Program Files\Sandboxie\Start.exe" /terminate_all

_________________
tzuk
View user's profileSend private message
Max100


Joined: 20 Oct 2009
Posts: 159
Reply with quote
tzuk wrote:
You can use the parameter /wait in Start.exe, this will cause Start.exe to suspend until the program ends.

You would need to change your desktop shortcut so it starts a batch script that runs outside the sandbox:

NewScript.bat:
Code:
"C:\Program Files\Sandboxie\Start.exe" /wait /box:Trash /hide_window "C:\svabi\program\start.bat"
"C:\Program Files\Sandboxie\Start.exe" /terminate_all


Unfortunately it doesn't work... in this case cmd window exits immediately without open nothing.
But if I omit last line in your script, script runs ok, opening start.bat in Trash sandbox.
View user's profileSend private message
tzuk


Joined: 22 Jun 2004
Posts: 15004
Reply with quote
OK, then try this instead of the first line --

Code:
start /wait "C:\Program Files\Sandboxie\Start.exe" /wait /box:Trash /hide_window "C:\svabi\program\start.bat"


The first /wait tells cmd.exe that you want to wait for Start.exe to finish.
The second /wait tells Start.exe that you want to wait for start.bat to finish.
View user's profileSend private message
Max100


Joined: 20 Oct 2009
Posts: 159
Reply with quote
tzuk wrote:
OK, then try this instead of the first line --

Code:
start /wait "C:\Program Files\Sandboxie\Start.exe" /wait /box:Trash /hide_window "C:\svabi\program\start.bat"


The first /wait tells cmd.exe that you want to wait for Start.exe to finish.
The second /wait tells Start.exe that you want to wait for start.bat to finish.


I've tried it now, but this line doesn't work either.
If I remove the first start /wait it works as usual, but without close all sandbox programs.
View user's profileSend private message
tzuk


Joined: 22 Jun 2004
Posts: 15004
Reply with quote
Alright, how about if you set CMD.EXE (which is the program running your "c:\svabi\program\start.bat" script),
as a leader program in the sandbox? That means that when the script ends and CMD.EXE exits, all the other
programs in the sandbox would be terminated as well. Could this be an easier way to do what you need?

Sandbox Settings > Program Stop > Leader Programs
View user's profileSend private message
Max100


Joined: 20 Oct 2009
Posts: 159
Reply with quote
tzuk wrote:
Alright, how about if you set CMD.EXE (which is the program running your "c:\svabi\program\start.bat" script),
as a leader program in the sandbox? That means that when the script ends and CMD.EXE exits, all the other
programs in the sandbox would be terminated as well. Could this be an easier way to do what you need?

Sandbox Settings > Program Stop > Leader Programs


Including CMD.exe in Leader Programs list, the program is opened, but it will be closed after 1 second. No time to do something.

However I solved this problem in a similar way, maintaining the usual shortcut:

Code:
"C:\Program Files\Sandboxie\Start.exe" /box:Trash /hide_window "C:\svabi\program\start.bat"


I dscovered that two processes remain in background after that I close the program.

So I went to program settings (right click on each of two processes) and I checked the first highlighted option (in program settings window)



These two entries will be added in Lingering Programs list, so if you add them from there it's the same:
http://www.sandboxie.com/index.php?ProgramStopSettings

Now I have just a question.... is it possible to terminate also sandboxie control at the end of script? /nosbiectrl doesn't work for me if I try to use the previous code in this post.
But if the workaround for this other thing is to run a .bat in a .bat, then I'd say... "no, thank you, it's good enough." Smile
View user's profileSend private message
tzuk


Joined: 22 Jun 2004
Posts: 15004
Reply with quote
Should be simpler this time. Something like --

Code:
TASKKILL /IM SbieCtrl.exe /F
View user's profileSend private message
Max100


Joined: 20 Oct 2009
Posts: 159
Reply with quote
Max100 wrote:
tzuk wrote:
Alright, how about if you set CMD.EXE (which is the program running your "c:\svabi\program\start.bat" script),
as a leader program in the sandbox? That means that when the script ends and CMD.EXE exits, all the other
programs in the sandbox would be terminated as well. Could this be an easier way to do what you need?

Sandbox Settings > Program Stop > Leader Programs


Including CMD.exe in Leader Programs list, the program is opened, but it will be closed after 1 second. No time to do something.

However I solved this problem in a similar way, maintaining the usual shortcut:

Code:
"C:\Program Files\Sandboxie\Start.exe" /box:Trash /hide_window "C:\svabi\program\start.bat"


I dscovered that two processes remain in background after that I close the program.

So I went to program settings (right click on each of two processes) and I checked the first highlighted option (in program settings window)



These two entries will be added in Lingering Programs list, so if you add them from there it's the same:
http://www.sandboxie.com/index.php?ProgramStopSettings



This workaround, necessary to close unneeded programs, doesn't work anymore starting from 3.69.03 version. Current 3.69.04 version is also affected.
In all versions before 3.69.03 Lingering Programs feature worked correctly with these steps.

If you need other instructions, just ask. Rolling Eyes
View user's profileSend private message
tzuk


Joined: 22 Jun 2004
Posts: 15004
Reply with quote
Ah, this probably has to do with the change I did to address this problem report:

http://www.sandboxie.com/phpbb/viewtopic.php?t=12868

Thanks for catching this so quickly. I'll see what I can do about it, I'll let you know in a couple of days.
View user's profileSend private message
tzuk


Joined: 22 Jun 2004
Posts: 15004
Reply with quote
I re-read the topic but I'm not sure I understand how you have it set up exactly.
Can you tell me which LingerProcess and LeaderProcess settings you have in effect?
View user's profileSend private message
Max100


Joined: 20 Oct 2009
Posts: 159
Reply with quote
tzuk wrote:
I re-read the topic but I'm not sure I understand how you have it set up exactly.
Can you tell me which LingerProcess and LeaderProcess settings you have in effect?


Code:
[Trash]

Enabled=y
ConfigLevel=7
Template=IExplore_Favorites_RecoverFolder
Template=PlugPlayService
Template=BlockPorts
Template=LingerPrograms
Template=Firefox_Phishing_DirectAccess
Template=AutoRecoverIgnore
RecoverFolder=%{374DE290-123F-4565-9164-39C4925E467B}%
RecoverFolder=%Personal%
RecoverFolder=%Desktop%
BlockDrivers=y
BlockWinHooks=y
BlockSysParam=y
BlockPassword=y
BlockFakeInput=n
BlockNetParam=y
LingerProcess=mflmma.exe
LingerProcess=mflmwin.exe


I don't use any LeaderProcess settings.
These executables are started together with the main software (ca-main.exe). Ca-main.exe is called from my batch file.
View user's profileSend private message
tzuk


Joined: 22 Jun 2004
Posts: 15004
Reply with quote
I'm sorry but I remain just as confused as before, and don't have a clue what I have to check.

Please pretend that nothing has been posted in this topic, and that you have to make a descriptive first post, which actually explains the problem. Because really, I have no idea what is the problem.
View user's profileSend private message
Max100


Joined: 20 Oct 2009
Posts: 159
Reply with quote
tzuk wrote:
I'm sorry but I remain just as confused as before, and don't have a clue what I have to check.

Please pretend that nothing has been posted in this topic, and that you have to make a descriptive first post, which actually explains the problem. Because really, I have no idea what is the problem.


I suggest you to read these steps carefully before applying them, so you can't make mistakes.

1) Install Sandboxie 3.69.02
2) Install this in a sandbox of your choice (press Avanti>, then Install and Fine).
3) Install this in the same sandbox as before (press Avanti, again Avanti, then Install. Before to press Fine, please unselect the checkbox "Eseguire Carpe-PC" .)

4) Create a file named "start.bat" with these lines:

Code:
sc start "Micro Focus License Manager"
start /wait ca-start.exe


5) Copy start.bat in c:\svabi\program\ folder.
6) Add these lines to the end of your sandbox configuration:

Code:
LingerProcess=mflmma.exe
LingerProcess=mflmwin.exe


7) Open start.bat from the sandbox. You will see a window with multiple radio buttons. Choose "Cittadino con Pin" radio button. Press Continua, and again Continua.
7a)Before to do anything, open separately Sandboxie control and keep it open without closing it. You will see 3 processes as in this image.
8)Now you can interact with the two windows on the screen started from the batch file. Close both of them using the typical red close button in top-right corner of title bar. When required, press "Si" button to confirm this operation.
9) Immediately after pressing"Si" button, take a look at Sandboxie control (as in step 7a), and you will see mflmma.exe & mflmwin.exe closed together with the main executable ca-main.exe.
10) Install any Sandboxie version after 3.69.02, and you won't see mflmma.exe & mflmwin.exe closed correctly, because in this case they remain loaded in background.
View user's profileSend private message
tzuk


Joined: 22 Jun 2004
Posts: 15004
Reply with quote
Thanks for the detailed explanation! I'll see what I can do.
View user's profileSend private message
[.06] Terminate programs after exiting from a script
You cannot 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 2  

Use the RSS feed to watch this topic for replies
  
  
 This topic is locked: you cannot edit posts or make replies.  

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