Solved

VBScript run a DOS command then simulate pressing enter

Posted on 2011-03-17
4
1,063 Views
Last Modified: 2012-05-11
I want to run a vbscript to do a backup process.  The backup is done by running a command line prompt the you supply the backup file name.  Once you enter this there is a screen that presents a message and asks you to press enter to continue.

I want to use VBscript to create the file name based on date and once the backup is created to copy it.  My problem is simulating the enter key.  Since this will be a scheduled task that will run while the server is logged off I can't use Send Keys.  I also thought about using a Batch file to run the command, however I can't find how to simulate the enter key with batch command's either as the backup command wants only the enter key, not 'y' for yes.
0
Comment
Question by:BKRsupport
  • 3
4 Comments
 
LVL 10

Expert Comment

by:aeklund
ID: 35160359
Assuming your backup program is called "backup.exe" what if you called it via vbscript like this:


oShell.Run "cmd.exe /c " & Chr(13) & "|backup.exe" 'Notice the pipe symbol |  Chr(13) = CR
0
 
LVL 1

Author Comment

by:BKRsupport
ID: 35164642
I had tried the pipe with chr(13), dosen't accept it.
0
 
LVL 1

Accepted Solution

by:
BKRsupport earned 0 total points
ID: 35165419
I found a solution for this via a Batch file.  If you create a text file with the line "press the Enter key" and save it as (ie enter.txt) then create a batch file with the line "backup.exe backupfilename.tgz < enter.txt" this will simluate pressing the enter key.  I just then use VB to create the file name based on todays date and call the batch file to run.
0
 
LVL 1

Author Closing Comment

by:BKRsupport
ID: 35196634
This solution resolved my issue.
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is an addendum to the following article: Acitve Directory based Outlook Signature (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_24950055.html) The script is fine, and works in normal client-server domains…
I met Paul Devereux (@pdevereux) today when I responded to his tweet asking “Anybody know how to automate adding files from disk to a folder in #outlook  ?”.  I replied back and told Paul that using automation, in this case scripting, to add files t…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

809 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