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

    370
    11
    76
    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:

    Code:
    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"
    Wscript.Quit
    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?

    Ta
     
    Last edited: Sep 21, 2012
    Certifications: AS Computing, A+, Network+, 70-680, 70-410
    WIP: MCSA: Server 2012

Share This Page

Loading...