Solved

Windows XP Close and Re-Open Application

Posted on 2013-01-05
8
683 Views
Last Modified: 2013-01-20
In Windows XP and Widnows 7 I need to be able to close an application (kill it's task) and re-open that applicatin after about 10 seconds. I know this can be donw with a scritp, but not sure how to write it. Maybe there is a simpler way of doing it.
0
Comment
Question by:datzent83
[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
  • 2
  • 2
  • 2
  • +2
8 Comments
 
LVL 38

Expert Comment

by:BillDL
ID: 38748007
What is the application, and exactly how is it listed when you open a CMD window and type this command?:

tasklist /v /fo csv
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 38748011
What are you trying to accomplish by doing that?  Do you know for sure that it will completely shutdown in 10 seconds?
0
 
LVL 11

Expert Comment

by:Joseph O'Loughlin
ID: 38750993
The paid version of Take Command from JPSoft includes the environment variable @WINPID which would facilitate scripting the above based on the title of the application.
However trickier (so not suggesting the above as a solution) is determining whether the application has hung, or whatever the required conditions are, as I doubt your intention is to kill the program every 10 seconds?
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 1

Accepted Solution

by:
bmarone earned 500 total points
ID: 38753099
set ProcessDir=C:\Program Files\Adobe\Acrobat 6.0\Reader
set ProcessName=AcroRd32.exe
taskkill /f /im %ProcessName%
:WaitTilDead
tasklist /fi "IMAGENAME eq %ProcessName%" |find "%ProcessName%"
if not errorlevel 1 goto WaitTilDead
SLEEP.EXE 10
start "window title" "%ProcessDir%\%ProcessName%"

The SLEEP.EXE is available in the Win2003 Resource Kit, linked thru:
http://www.petri.co.il/download_windows_2003_reskit_tools.htm
0
 

Author Comment

by:datzent83
ID: 38780143
Will SLEEP.EXE work with Window XP and Windows 7?
0
 
LVL 11

Expert Comment

by:Joseph O'Loughlin
ID: 38781179
yes
0
 

Author Comment

by:datzent83
ID: 38781199
So I run SLEEP.EXE and execute the following script?

set ProcessDir=C:\Program Files\Adobe\Acrobat 6.0\Reader
set ProcessName=AcroRd32.exe
taskkill /f /im %ProcessName%
:WaitTilDead
tasklist /fi "IMAGENAME eq %ProcessName%" |find "%ProcessName%"
if not errorlevel 1 goto WaitTilDead
SLEEP.EXE 10
start "window title" "%ProcessDir%\%ProcessName%"
0
 
LVL 1

Assisted Solution

by:bmarone
bmarone earned 500 total points
ID: 38781250
In the interest of stating the obvious, "this script" needs to be modified to change the ProcessDir and ProcessName variables from the Acrobat Reader example to the one you're specifically targeting. I'm guessing you know which process name you're killing ( in Task Manager) and in which folder that EXE resides, but excluded it from your question for confidentiality.

As SLEEP.EXE is called in the script.  You do need to put the SLEEP.EXE in the same folder as this script, or maybe put SLEEP.EXE in C:\WINDOWS\SYSTEM32, or put it in the root C:\ and change the line in the script to be "C:\SLEEP.EXE 10" (no quotes)

SLEEP.EXE is in the Resource Kit, not included in Windows XP, so you need to follow the link, download the whole resource kit, and either extract it all or use 7-ZIP to extract only SLEEP.EXE

What the script does is try to force-kill the process, and then loops until the process no longer shows in the tasklist, and then sleeps 10 seconds, and then runs the task again.  It's your call whether you want to sleep for 10 seconds, or change it to 5 (secs), or just REM it out if your only interest was giving the process time to end, as the loop is already checking that. But also note, if the process never actually force-kills, this thing will loop forever.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
There are many software programs on offer that will claim to magically speed up your computer. The best advice I can give you is to avoid them like the plague, because they will often cause far more problems than they solve. Try some of these "do it…
This Micro Tutorial will give you basic overview of the control panel section on Windows 7. It will depth in Network and Internet, Hardware and Sound, etc. This will be demonstrated using Windows 7 operating system.
This Micro Tutorial will give you a introduction in two parts how to utilize Windows Live Movie Maker to its maximum capability. This will be demonstrated using Windows Live Movie Maker on Windows 7 operating system.

734 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