Solved

Close All Applications Command

Posted on 2008-10-30
3
477 Views
Last Modified: 2012-08-13
Experts,

A network backup program requires that all my applications be closed on my machine before it will back up my data.  I'd like to create a batch job that kicks in at a certain time and closes them all automatically so I don't forget.  Is there a way to do this in WindowsXP?

0
Comment
Question by:NigelRocks
3 Comments
 
LVL 28

Accepted Solution

by:
Bill Bach earned 200 total points
ID: 22845428
Closing applications might be tough because it's hard to tell what is an application and what is a service from an automated script.  

What about just logging off?  You can enable a screen-saver that forces a logoff (in case you forget).  Logging off leaves the OS running, but with no applications running (only services).

Check here to get started:
    http://windowsxp.mvps.org/winexit.htm
0
 
LVL 7

Assisted Solution

by:talker2004
talker2004 earned 150 total points
ID: 22845457
This is beyond the capabilities of a batch file.

I would be able to do this with a programming language like vb.net or c#.

However there is a new scripting tool called powershell which i am sure could do it.
This is the new way to do batch files. Unfortunately i have no experience with powershell but i found an article that explains how to stop a process via powershell.

http://www.computerperformance.co.uk/powershell/powershell_process.htm

0
 
LVL 38

Assisted Solution

by:Shift-3
Shift-3 earned 150 total points
ID: 22845845
Here's a fairly crude way to do it using vbscript.

Paste the script below into a text file with a .vbs extension.  Running it will terminate any processes running under the current user's credentials.  

Be warned that this just kills the processes.  It does not close programs gracefully, so any unsaved data will be lost.  It might produce undesirable results with some programs.  Use with caution.


Set objShell = CreateObject("WScript.Shell")

strUserName = objShell.ExpandEnvironmentStrings("%username%")

strUserDomain = objShell.ExpandEnvironmentStrings("%userdomain%")
 

Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
 

Set colProcessList = objWMIService.ExecQuery _

    ("Select * from Win32_Process")
 

For Each objProcess in colProcessList

    objProcess.GetOwner strProcUser, strProcDomain

    If LCase(strProcDomain & "\" & strProcUser) = LCase(strUserDomain & "\" & strUserName) Then

        objProcess.Terminate

    End If

Next

Open in new window

0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
In this article, I will show you HOW TO: Install VMware Tools for Windows on a VMware Windows virtual machine on a VMware vSphere Hypervisor 6.5 (ESXi 6.5) Host Server, using the VMware Host Client. The virtual machine has Windows Server 2016 instal…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now