Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #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

  • #2
    Regular Coder mic2100's Avatar
    Join Date
    Feb 2006
    Location
    Scunthorpe
    Posts
    562
    Thanks
    15
    Thanked 28 Times in 27 Posts
    Try this

    Code:
    WScript.Quit [exitcode]

  • #3
    New Coder
    Join Date
    Apr 2006
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts
    isn't that just going to terminate the script it's in? can it shut down a program?

  • #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
    Last edited by ez4me2c3d; 10-16-2007 at 05:29 PM. Reason: Fixed code
    anthony

  • #5
    New Coder
    Join Date
    Apr 2006
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #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

  • #7
    New to the CF scene
    Join Date
    May 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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,


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •