Jump to content
Sign in to follow this  
cmcolema

Close all programs and start a new one

Recommended Posts

cmcolema

I am looking to find a script that will close all programs and then allow me to start a new one. I want to then shut down the computer after the new one finishes running.

The purpose will be to make sure all programs are closed before we run a program that ensures our video downloads are stopped before we shut down a computer at night. Any help on this would be greatly appreciated.

Share this post


Link to post
Share on other sites
Varian

Use at your own risk:

$Processes = ProcessList()

For $i = 1 to $Processes[0][0]
    ;add more types to match; killing certain processes (like lsass.exe) will cause the machine to shutdown
    ;or become unstable...use with caution
    If StringRegExp($Processes[$i][0], "svchost.exe|lsass.exe|csrss.exe|explorer.exe", 0) Then ContinueLoop
    ProcessClose($Processes[$i][1])
    ProcessWaitClose($Processes[$i][1], 5)
Next

Exit Run("YourProgram.exe")

Share this post


Link to post
Share on other sites
cmcolema

So I need to list each process I want to close in the script?

will closeing explore.exe close every program sitting on the OS and then restarting explore.exe so I can start a new program work?

Share this post


Link to post
Share on other sites
picea892

Hi

I think you're misreading the script, Continue Loop will take it back to the for statement. So you need to list all programs you are not closing. That is why this is somewhat dangerous. We can only guess at what processes are running on your computer. What I would do is press Ctl+Shift+Esc and go through the process list and google it. (What is svchost.exe), that will give you a sense of what processes should be excluded.

Closing Explorer.exe will do nothing. If you have a file manager replacement software (tabbyfile, metapath. etc.) you can still use your computer normally. Of course you won't have a start menu, desktop icons or a taskbar. But who needs that eye candy anyways :P

Good luck

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×