Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Windows XP Close and Re-Open Application

Posted on 2013-01-05
8
Medium Priority
?
688 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 84

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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
LVL 1

Accepted Solution

by:
bmarone earned 2000 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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Assume you have an outside contractor who comes in seasonally or once a week to do some work in your office, but you only want to give him access to the programs and files he needs and keep all other documents and programs private. Can you do this o…
Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
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 the overview of Microsoft Security Essentials. This is a free anti-virus software that guards your PC against viruses, spyware, worms, and other malicious software. This will be demonstrated using Windows…
Suggested Courses

661 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