.VBS Close/Abort Script

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

  1. BB88

    BB88 Kilobyte Poster Gold Member

    383
    13
    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: CompTIA A+, CompTIA Network+, MCSA: Office 365,, 70-410, 70-680
    WIP: CompTIA: Security+

Share This Page

Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.