Go Back   CodingForums.com > :: Computing & Sciences > Computer Programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-15-2007, 06:55 PM   PM User | #1
thewillum
New Coder

 
Join Date: Apr 2006
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
thewillum is an unknown quantity at this point
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
thewillum is offline   Reply With Quote
Old 10-16-2007, 09:51 AM   PM User | #2
mic2100
Regular Coder

 
mic2100's Avatar
 
Join Date: Feb 2006
Location: Scunthorpe
Posts: 562
Thanks: 15
Thanked 28 Times in 27 Posts
mic2100 is on a distinguished road
Try this

Code:
WScript.Quit [exitcode]
mic2100 is offline   Reply With Quote
Old 10-16-2007, 02:07 PM   PM User | #3
thewillum
New Coder

 
Join Date: Apr 2006
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
thewillum is an unknown quantity at this point
isn't that just going to terminate the script it's in? can it shut down a program?
thewillum is offline   Reply With Quote
Old 10-16-2007, 05:27 PM   PM User | #4
ez4me2c3d
Regular Coder

 
Join Date: Dec 2002
Location: Minneapolis, MN
Posts: 208
Thanks: 0
Thanked 1 Time in 1 Post
ez4me2c3d is an unknown quantity at this point
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
ez4me2c3d is offline   Reply With Quote
Old 10-16-2007, 06:21 PM   PM User | #5
thewillum
New Coder

 
Join Date: Apr 2006
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
thewillum is an unknown quantity at this point
Quote:
What you are asking is, how to gracefully shutdown an application (such as Internet Explorer) via a VBScript. Correct?
Correct... and "Gracefully" is a good way to put it.

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
thewillum is offline   Reply With Quote
Old 10-16-2007, 07:01 PM   PM User | #6
thewillum
New Coder

 
Join Date: Apr 2006
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
thewillum is an unknown quantity at this point
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
thewillum is offline   Reply With Quote
Old 05-26-2011, 09:10 AM   PM User | #7
Sam_123
New to the CF scene

 
Join Date: May 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Sam_123 is an unknown quantity at this point
Force Internet Explorer to close, when system remails idle for 10 mins

Dear all,

I need VB script which can help me to allow Force Internet Explorer to close, when system remails idle for 10 mins..

Thanks,
Sam_123 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:18 AM.


Advertisement
Log in to turn off these ads.