Solved

VBScript run a DOS command then simulate pressing enter

Posted on 2011-03-17
4
1,068 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction During my participation as a VBScript contributor at Experts Exchange, one of the most common questions I come across is this: "I have a script that runs against only one computer. How can I make it run against a list of computers in …
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

726 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