Jump to content

Recommended Posts

Posted

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.

Posted

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")
Posted

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?

Posted

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

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
×
×
  • Create New...