stop app, run script, restart app
Author |
Message |
A Wad #1 / 6
|
 stop app, run script, restart app
I am hoping someone can help me with the simple script. I am running a Win98 machine. Here's what I'm trying to do: Stop an application running in the system tray, run a basic maintenance script, and restart the application when maintenance is done. I guess these would each be three distinct scripts "automated" through task manager to run at different times. Here's what I have. 'Stop application (doesn't work) on error resume next set WPApp = getobject(, "winproxy.application") if err then wscript.quit WPApp.quit 'Run maintenance (works fine) dim objWshShell set objWshShell = WScript.CreateObject("WScript.Shell") objWshShell.Run("c:\progra~1\access~1 backup\msbackup") Wscript.sleep 3000 objWshShell.Sendkeys "%S" Set objWshShell = Nothing 'Restart app (works fine) Sub RunProgram(Filename, Wait) Set WSHShell = WScript.CreateObject("WScript.Shell") RetVal = WSHShell.Run(Filename, Wait) End Sub Call RunProgram("C:\Progra~1\ositis\winproxy.exe", True)
|
Fri, 30 May 2003 03:37:11 GMT |
|
 |
Michael Harri #2 / 6
|
 stop app, run script, restart app
You'll probably need to contact the vendor for WinProxy (www.winproxy.com) to find out if there is a safe programmatic way to shutdown WinProxy from a script client... -- Michael Harris Microsoft.MVP.Scripting --
Please do not email questions - post them to the newsgroup instead. --
Quote: > I am hoping someone can help me with the simple script. > I am running a Win98 machine. Here's what I'm trying to do: Stop an > application running in the system tray, run a basic maintenance script, and > restart the application when maintenance is done. I guess these would each > be three distinct scripts "automated" through task manager to run at > different times. Here's what I have. > 'Stop application (doesn't work) > on error resume next > set WPApp = getobject(, "winproxy.application") > if err then wscript.quit > WPApp.quit > 'Run maintenance (works fine) > dim objWshShell > set objWshShell = WScript.CreateObject("WScript.Shell") > objWshShell.Run("c:\progra~1\access~1 backup\msbackup") > Wscript.sleep 3000 > objWshShell.Sendkeys "%S" > Set objWshShell = Nothing > 'Restart app (works fine) > Sub RunProgram(Filename, Wait) > Set WSHShell = WScript.CreateObject("WScript.Shell") > RetVal = WSHShell.Run(Filename, Wait) > End Sub > Call RunProgram("C:\Progra~1\ositis\winproxy.exe", True)
|
Fri, 30 May 2003 05:17:29 GMT |
|
 |
A Wad #3 / 6
|
 stop app, run script, restart app
I use winproxy merely as an example. I have four apps running in the taskbar which I need to stop in order to run backup, degfrag, & scandisk using my WSH scripts. Is there a way (or method) to accessing an non-Office application in order to close it using scripting?
Quote: > You'll probably need to contact the vendor for WinProxy (www.winproxy.com) > to find out if there is a safe programmatic way to shutdown WinProxy from a > script client... > -- > Michael Harris > Microsoft.MVP.Scripting > --
> Please do not email questions - post them to the newsgroup instead. > --
> > I am hoping someone can help me with the simple script. > > I am running a Win98 machine. Here's what I'm trying to do: Stop an > > application running in the system tray, run a basic maintenance script, > and > > restart the application when maintenance is done. I guess these would > each > > be three distinct scripts "automated" through task manager to run at > > different times. Here's what I have. > > 'Stop application (doesn't work) > > on error resume next > > set WPApp = getobject(, "winproxy.application") > > if err then wscript.quit > > WPApp.quit > > 'Run maintenance (works fine) > > dim objWshShell > > set objWshShell = WScript.CreateObject("WScript.Shell") > > objWshShell.Run("c:\progra~1\access~1 backup\msbackup") > > Wscript.sleep 3000 > > objWshShell.Sendkeys "%S" > > Set objWshShell = Nothing > > 'Restart app (works fine) > > Sub RunProgram(Filename, Wait) > > Set WSHShell = WScript.CreateObject("WScript.Shell") > > RetVal = WSHShell.Run(Filename, Wait) > > End Sub > > Call RunProgram("C:\Progra~1\ositis\winproxy.exe", True)
|
Fri, 30 May 2003 10:12:51 GMT |
|
 |
Michael Harri #4 / 6
|
 stop app, run script, restart app
If it has a UI (i.e, a visible main window with a title), you can try using a combination of WshShell.AppActivate (as a function call so you can test for success) and WshShell.Sendkeys "%{F4}}" (the standard Alt+F4 key combination to close a window). Depending on the application AND the OS version, this is usually a hit or miss proposition. An **extreme** mechanism (**not** generally recommended) is to simply kill the process (just like you would from Task Manager for a app/process that has stopped responding). You would need WMI installed in order to do this. It isn't recommended since the app/process doesn't get the chance to do any of it's normal shutdown processing. This can lead to some very undesirable side-effects, like lost data, memory leaks, etc. -- Michael Harris Microsoft.MVP.Scripting --
Please do not email questions - post them to the newsgroup instead. --
Quote: > I use winproxy merely as an example. I have four apps running in the > taskbar which I need to stop in order to run backup, degfrag, & scandisk > using my WSH scripts. Is there a way (or method) to accessing an non-Office > application in order to close it using scripting?
> > You'll probably need to contact the vendor for WinProxy (www.winproxy.com) > > to find out if there is a safe programmatic way to shutdown WinProxy from > a > > script client... > > -- > > Michael Harris > > Microsoft.MVP.Scripting > > --
> > Please do not email questions - post them to the newsgroup instead. > > --
> > > I am hoping someone can help me with the simple script. > > > I am running a Win98 machine. Here's what I'm trying to do: Stop an > > > application running in the system tray, run a basic maintenance script, > > and > > > restart the application when maintenance is done. I guess these would > > each > > > be three distinct scripts "automated" through task manager to run at > > > different times. Here's what I have. > > > 'Stop application (doesn't work) > > > on error resume next > > > set WPApp = getobject(, "winproxy.application") > > > if err then wscript.quit > > > WPApp.quit > > > 'Run maintenance (works fine) > > > dim objWshShell > > > set objWshShell = WScript.CreateObject("WScript.Shell") > > > objWshShell.Run("c:\progra~1\access~1 backup\msbackup") > > > Wscript.sleep 3000 > > > objWshShell.Sendkeys "%S" > > > Set objWshShell = Nothing > > > 'Restart app (works fine) > > > Sub RunProgram(Filename, Wait) > > > Set WSHShell = WScript.CreateObject("WScript.Shell") > > > RetVal = WSHShell.Run(Filename, Wait) > > > End Sub > > > Call RunProgram("C:\Progra~1\ositis\winproxy.exe", True)
|
Fri, 30 May 2003 10:37:37 GMT |
|
 |
Michael Harri #5 / 6
|
 stop app, run script, restart app
Oops, too many curly braces ;-) WshShell.Sendkeys "%{F4}" -- Michael Harris Microsoft.MVP.Scripting --
Please do not email questions - post them to the newsgroup instead. --
Quote: > If it has a UI (i.e, a visible main window with a title), you can try using > a combination of WshShell.AppActivate (as a function call so you can test > for success) and WshShell.Sendkeys "%{F4}}" (the standard Alt+F4 key > combination to close a window). Depending on the application AND the OS > version, this is usually a hit or miss proposition. > An **extreme** mechanism (**not** generally recommended) is to simply kill > the process (just like you would from Task Manager for a app/process that > has stopped responding). You would need WMI installed in order to do this. > It isn't recommended since the app/process doesn't get the chance to do any > of it's normal shutdown processing. This can lead to some very undesirable > side-effects, like lost data, memory leaks, etc. > -- > Michael Harris > Microsoft.MVP.Scripting > --
> Please do not email questions - post them to the newsgroup instead. > --
> > I use winproxy merely as an example. I have four apps running in the > > taskbar which I need to stop in order to run backup, degfrag, & scandisk > > using my WSH scripts. Is there a way (or method) to accessing an > non-Office > > application in order to close it using scripting?
> > > You'll probably need to contact the vendor for WinProxy > (www.winproxy.com) > > > to find out if there is a safe programmatic way to shutdown WinProxy > from > > a > > > script client... > > > -- > > > Michael Harris > > > Microsoft.MVP.Scripting > > > --
> > > Please do not email questions - post them to the newsgroup instead. > > > --
> > > > I am hoping someone can help me with the simple script. > > > > I am running a Win98 machine. Here's what I'm trying to do: Stop an > > > > application running in the system tray, run a basic maintenance > script, > > > and > > > > restart the application when maintenance is done. I guess these would > > > each > > > > be three distinct scripts "automated" through task manager to run at > > > > different times. Here's what I have. > > > > 'Stop application (doesn't work) > > > > on error resume next > > > > set WPApp = getobject(, "winproxy.application") > > > > if err then wscript.quit > > > > WPApp.quit > > > > 'Run maintenance (works fine) > > > > dim objWshShell > > > > set objWshShell = WScript.CreateObject("WScript.Shell") > > > > objWshShell.Run("c:\progra~1\access~1 backup\msbackup") > > > > Wscript.sleep 3000 > > > > objWshShell.Sendkeys "%S" > > > > Set objWshShell = Nothing > > > > 'Restart app (works fine) > > > > Sub RunProgram(Filename, Wait) > > > > Set WSHShell = WScript.CreateObject("WScript.Shell") > > > > RetVal = WSHShell.Run(Filename, Wait) > > > > End Sub > > > > Call RunProgram("C:\Progra~1\ositis\winproxy.exe", True)
|
Fri, 30 May 2003 10:41:46 GMT |
|
 |
A Wad #6 / 6
|
 stop app, run script, restart app
Here's the response from Winproxy tech support regarding their app. I am using this in combination with Mr. Harris's suggestions to "automate what I'm too lazy to do myself. Winproxy Tech Support At 12/12/2000 01:26 PM we wrote - This command ought to help you: Form a DOS prompt, at the Winproxy program files directory, you can type in this: winproxy /ShutItDown and that shuts it down. It is case sensitive, so the S, I, and D need to be capitalized.
Quote: > I am hoping someone can help me with the simple script. > I am running a Win98 machine. Here's what I'm trying to do: Stop an > application running in the system tray, run a basic maintenance script, and > restart the application when maintenance is done. I guess these would each > be three distinct scripts "automated" through task manager to run at > different times. Here's what I have. > 'Stop application (doesn't work) > on error resume next > set WPApp = getobject(, "winproxy.application") > if err then wscript.quit > WPApp.quit > 'Run maintenance (works fine) > dim objWshShell > set objWshShell = WScript.CreateObject("WScript.Shell") > objWshShell.Run("c:\progra~1\access~1 backup\msbackup") > Wscript.sleep 3000 > objWshShell.Sendkeys "%S" > Set objWshShell = Nothing > 'Restart app (works fine) > Sub RunProgram(Filename, Wait) > Set WSHShell = WScript.CreateObject("WScript.Shell") > RetVal = WSHShell.Run(Filename, Wait) > End Sub > Call RunProgram("C:\Progra~1\ositis\winproxy.exe", True)
|
Sun, 01 Jun 2003 06:00:13 GMT |
|
|
|