Solved

VBScript run a DOS command then simulate pressing enter

Posted on 2011-03-17
4
1,066 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Server 2012 management. 5 54
Subtraction v Hex2Dec in vbscript 6 35
Convert this script to work with Windows 10 ftp 36 90
78 files, need to delete row 2 in every file 3 26
Recently I finished a vbscript that I thought I'd share.  It uses a text file with a list of server names to loop through and get various status reports, then writes them all into an Excel file.  Originally it was put together for our Altiris server…
In this article we want to have a look at the directory attributes which are used by Microsoft to store the so called Security Identifiers (SID). These SIDs plays an important role in delegating and granting permissions and in authentication of trus…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

742 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