Solved

Windows XP Close and Re-Open Application

Posted on 2013-01-05
8
679 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 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Suggested Solutions

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 try to extract and to view the contents of a Microsoft Update Standalone Package (MSU) for Windows Vista, you cannot extract the files from the MSU. Here we are going to explain how to extract those hotfix details without using any third pa…
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
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.

778 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