Solved

Windows XP Close and Re-Open Application

Posted on 2013-01-05
8
675 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
  • 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 82

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
 
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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

I have published numerous articles here at Experts Exchange that present programs/scripts written in a language called AutoHotkey. Each of those articles has a brief paragraph describing where to download the product and how to install it. I have al…
When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup". After a while, you have entered a loop for Auto repair which does not fix anything and you will be in a  panic as all your work w…
This Micro Tutorial will teach you how to change your appearance and customize your Windows 7 interface to your unique preference. This will be demonstrated using Windows 7 operating system.
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…

743 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

14 Experts available now in Live!

Get 1:1 Help Now