Solved

Windows XP Close and Re-Open Application

Posted on 2013-01-05
8
680 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
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

The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Windows Updates Batch Files (now with executables!) 32 59
multiple reboots in a pc.. (event id 6006) 5 59
Upgrade Windows 7 pro to Enterprise 8 78
Upgrading Windows 7 2 23
New Windows 7 Installations take days for Windows-Updates to show up and install. This can easily be fixed. I have finally decided to write an article because this seems to get asked several times a day lately. This Article and the Links apply to…
When you try to share a printer , you may receive one of the following error messages. Error message when you use the Add Printer Wizard to share a printer: Windows could not share your printer. Operation could not be completed (Error 0x000006…
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.
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.

827 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