vbscript to send charactors to an existing running program

Posted on 2007-10-09
Last Modified: 2012-05-05
I need to send charactors to a program that is running called DBC.EXE so that it will gracefully exit when a user logs out but forgets to close the program correctly.

I need to send ESC 3 times, with a pause each time, then send the Y charactor.

I have little to no VBscript  experiance and any help would be greatly appriciated.
Question by:Darkstriker69
    1 Comment
    LVL 11

    Accepted Solution

    Have a look at the help for sendkeys.

    It will be something like

    pauseperiod = 5000 ' time in milliseconds
    set objShell = CreateObject ("WScript.Shell")
    objShell.AppActivate "DBC.exe"  ' whatever it says on the title bar
    objShell.SendKeys "{ESC}"
    WScript.Sleep pauseperiod
    objShell.SendKeys "{ESC}"
    WScript.Sleep pauseperiod
    objShell.SendKeys "{ESC}"
    WScript.Sleep pauseperiod
    objShell.SendKeys "Y"

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Unlike scripting languages such as C# where a semi-colon is used to indicate the end of a command, Microsoft's VBScript language relies on line breaks to determine when a command begins and ends. As you can imagine, this quickly results in messy cod…
    This is an addendum to the following article: Acitve Directory based Outlook Signature ( The script is fine, and works in normal client-server domains…
    This video discusses moving either the default database or any database to a new volume.
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now