1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

.VBS Close/Abort Script

Discussion in 'Scripting & Programming' started by BB88, Sep 21, 2012.

  1. BB88

    BB88 Kilobyte Poster Gold Member

    Hi there, I am using a program which is run when logged in. To call it, and run successfully I am using the RunAs command:

    Option Explicit
    WScript.Sleep 300000
    Dim oShell
    Set oShell= Wscript.CreateObject("WScript.Shell")
    oShell.Run "runas /profile /user:userhere ""WScript.exe locationoffile"""
    WScript.Sleep 100
    oShell.Sendkeys "passwordhere"
    WScript.Sleep 100
    oShell.SendKeys "{ENTER}"
    WScript.Sleep 10000
    oShell.SendKeys "^+C"
    Basically it is called when users log on, and after 5 minutes its run. In some instances, people have locked their workstation after logging in, before 5 minutes elapsed, and upon unlocking, are greeted with a command prompt sitting there. I would like to replace the CTRL+C, as this only works if the Command Prompt is the active window!

    How can I force close the script window if the password isn't entered?

    Last edited: Sep 21, 2012
    Certifications: CompTIA A+, CompTIA Network+, MCSA: Office 365,, 70-410, 70-680
    WIP: PRINCE2 Foundation, MCSA: Server 2012, PRINCE2 Practioner

Share This Page