![]() |
|
|
|||||||
![]() |
|
|
Thread Tools | Rate Thread |
|
|
PM User | #1 |
|
New Coder ![]() Join Date: Apr 2006
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
closing a program in VBScript.
Hey... I need some help safely closing a program, preferably using vbscript.
First, this is what I'm trying to do. I've got a program that creates a HUGE history database that is completely useless to me. I'm trying to close the program (which runs automatically on startup), delete the history.db, and restart the program. I have the scripts to delete the file and start the program, that's easy. I tried simply terminating the process, and that does end the program, but when restarting the program after terminating the process I get an error... I basically have to go "File > Exit" in order for the program to restart properly. What I do not need is a script to terminate a process. I have that script. I'd prefer to get this using vbscript, but would gladly use something else, however my programming knowledge is extremely limited. Again, what I'm looking for is a script which would safely shut down a program as if I had used File>Exit. Thanks if you can help. -Bill |
|
|
|
|
|
PM User | #4 |
|
Regular Coder ![]() Join Date: Dec 2002
Location: Minneapolis, MN
Posts: 208
Thanks: 0
Thanked 1 Time in 1 Post
![]() |
Correct WScript.Quit just ends the script that is running.
What you are asking is, how to gracefully shutdown an application (such as Internet Explorer) via a VBScript. Correct? The only way I know to do this is to launch the app from within the VBScript, then use the apps "shutdown" method. See example below: Code:
set oIE = CreateObject("InternetExplorer.Application")
oIE.Navigate "about:blank"
Do
Loop While oIE.Busy
oIE.Visible = True
Do Until oShell.AppActivate("about:blank - Microsoft Internet Explorer")
Loop
oIE.Document.WriteLn "<html><head><title>Page Title</title></head><body><div id='output'>test</div></body></html>"
Set oDIV = oIE.Document.All("output")
'Wait 5 seconds then change the output int the window
Wscript.Sleep 5000
oDIV.InnerHTML = "I changed it"
'Wait 5 seconds then close the application
Wscript.Sleep 5000
oIE.Quit
__________________
anthony Last edited by ez4me2c3d; 10-16-2007 at 05:29 PM.. Reason: Fixed code |
|
|
|
|
|
PM User | #5 | |
|
New Coder ![]() Join Date: Apr 2006
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
Quote:
I don't think that opening and closing the program from within the same script will work for me, as this program is an "always-on" aside from the short period I want to shut it down to delete its history database. I have had another suggestion that I'm working on right now, if that works I'll post it here... Thanks for the responses. -Bill |
|
|
|
|
|
|
PM User | #6 |
|
New Coder ![]() Join Date: Apr 2006
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
This article has a way that works perfectly for what I was trying to do... Thanks to those who tried to help.
http://www.codeproject.com/useritems/gopal_code.asp |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Rate This Thread | |
|
|