?
Solved

Close All Applications Command

Posted on 2008-10-30
3
Medium Priority
?
483 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 28

Accepted Solution

by:
Bill Bach earned 800 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 600 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 600 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

Manage your data center from practically anywhere

The KN8164V features HD resolution of 1920 x 1200, FIPS 140-2 with level 1 security standards and virtual media transmissions at twice the speed. Built for reliability, the KN series provides local console and remote over IP access, ensuring 24/7 availability to all servers.

Question has a verified solution.

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

This article is a collection of issues that people face from time to time and possible solutions to those issues. I hope you enjoy reading it.
When asking a question in a forum or creating documentation, screenshots are vital tools that can convey a lot more information and save you and your reader a lot of time
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Suggested Courses

764 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