Insert keystroke into executed batch command
Moderator: DosItHelp
Insert keystroke into executed batch command
Sorry, couldn't think of a better subject line.
I am executing a string of simple calls to xxcopy using a batch file.
Each call to xxcopy (3 separate calls) backs up data to an external hard drive, but when xxcopy initiates it splashes a "WARNING" screen that requires "Press any key except <ESC> within 2 minutes to continue." Without pressing a key within 2 minutes the xxcopy fails to execute the actual backup commands and there doesn't seem to be any xxcopy switch that will allow me to bypass this stupid warning screen thus making an automated backup .bat file useless.
Since there isn't an xxcopy switch to bypass the splash screen, I was hoping there was some way within the .bat file to actually pass a carriage return or key press while the xxcopy was waiting on a key to be pressed.
Since control is owned by xxcopy and the .bat is waiting on control to be returned before executing the next command, I wouldn't think this is possible (unless I was running a scripting language like Expect). However, I figured if anyone would know or know how to do it they would be on this forum.
Thanks.
I am executing a string of simple calls to xxcopy using a batch file.
Each call to xxcopy (3 separate calls) backs up data to an external hard drive, but when xxcopy initiates it splashes a "WARNING" screen that requires "Press any key except <ESC> within 2 minutes to continue." Without pressing a key within 2 minutes the xxcopy fails to execute the actual backup commands and there doesn't seem to be any xxcopy switch that will allow me to bypass this stupid warning screen thus making an automated backup .bat file useless.
Since there isn't an xxcopy switch to bypass the splash screen, I was hoping there was some way within the .bat file to actually pass a carriage return or key press while the xxcopy was waiting on a key to be pressed.
Since control is owned by xxcopy and the .bat is waiting on control to be returned before executing the next command, I wouldn't think this is possible (unless I was running a scripting language like Expect). However, I figured if anyone would know or know how to do it they would be on this forum.
Thanks.
Re: Insert keystroke into executed batch command
try this complicated batch file (with JS inside)
- not tested, because I can't reproduce your problem in my environment
- replace "xxcopy /?" to your xxcopy calls (lead ECHO command required!)
- replace "Press any key" to any other key text if need
- your own BAT code must be between /* and */ marks
- not tested, because I can't reproduce your problem in my environment
- replace "xxcopy /?" to your xxcopy calls (lead ECHO command required!)
- replace "Press any key" to any other key text if need
- your own BAT code must be between /* and */ marks
Code: Select all
@set @x=0 /*
@echo off
(
echo xxcopy /?
echo xxcopy /?
echo xxcopy /?
)|cscript //nologo /e:jscript "%~f0" "Press any key"
@exit */
wss = WScript.CreateObject("WScript.Shell");
while (!WScript.StdIn.AtEndOfStream) {
cmd = WScript.StdIn.ReadLine();
foo = wss.Exec(cmd);
while (!foo.StdOut.AtEndOfStream) {
str = foo.StdOut.ReadLine();
WScript.Echo(str);
if (str.indexOf(WScript.Arguments.Item(0))>0) {
WScript.Sleep(500);
wss.SendKeys("\r");
}
}
}
Re: Insert keystroke into executed batch command
I use Robocopy for such tasks but you may be interested in having a look at the information the link below provides.
http://www.xxcopy.com/xxgroup/m08/msg08387.htm
Best wishes!
http://www.xxcopy.com/xxgroup/m08/msg08387.htm
Best wishes!
Re: Insert keystroke into executed batch command
Ocalabob: Thanks for the link. I thought this warning message was a result of xxcopy thinking the copy to an external harddrive (via a logical mapping, ie: H:\) that xxcopy was seeing this as a network copy and thus spitting out the warning message. There is explicit documentation within the various versions (free, home, professional) that indicate certain features are restricted or, at a minimum, paused needing user interaction to continue. Never made sense to me that xxcopy would treat an external harddrive as a network copy. So thanks for the link, that clears up my perception of the splash screen. I am going to now try the /WVO switch
Amel27: JS inside of a .bat file? I had no idea that could be JS could be implemented that way. I literally only thought JS was for browsers. A very interesting approach, basically using JS as an Expect script, but within a BATCH script. I am going to toy with it and see what happens, could possibly open up a new world of DOS for me. Thanks.
Amel27: JS inside of a .bat file? I had no idea that could be JS could be implemented that way. I literally only thought JS was for browsers. A very interesting approach, basically using JS as an Expect script, but within a BATCH script. I am going to toy with it and see what happens, could possibly open up a new world of DOS for me. Thanks.
Re: Insert keystroke into executed batch command
Ocalabob:
Found in the current xxcopy command reference:
/WV0 This switch is now obsolete and has no effect.
/WV This switch is now obsolete and has no effect.
I was not able find any replacement switch to ignore window versioning.
Found in the current xxcopy command reference:
/WV0 This switch is now obsolete and has no effect.
/WV This switch is now obsolete and has no effect.
I was not able find any replacement switch to ignore window versioning.
Re: Insert keystroke into executed batch command
Ok...from xxcopy's version updates:
2.96.5 2008-01-08 Tested with Windows XP Service Pack 3
so I don't get why I am getting the splash warning message, look like I am going to have to try Amel27s suggestion - if in fact JS can be implemented in a batch file.
2.96.5 2008-01-08 Tested with Windows XP Service Pack 3
so I don't get why I am getting the splash warning message, look like I am going to have to try Amel27s suggestion - if in fact JS can be implemented in a batch file.
-
- Expert
- Posts: 391
- Joined: 19 Mar 2009 08:47
- Location: Iowa
Re: Insert keystroke into executed batch command
Can't something like this be done:
echo.y|xxcopy . . .
or
xxcopy ... < echo.y
or
echo.y>y.txt
xxcopy ... <y.txt
or
echo.y>y.txt
type y.txt|xxcopy ...
I thought some variation of those options were typically able to do the "press any key" idea . . .
echo.y|xxcopy . . .
or
xxcopy ... < echo.y
or
echo.y>y.txt
xxcopy ... <y.txt
or
echo.y>y.txt
type y.txt|xxcopy ...
I thought some variation of those options were typically able to do the "press any key" idea . . .
Re: Insert keystroke into executed batch command
It would be too simple, but unfortunately XXCOPY not work with StdInput...avery_larry wrote:echo.y|xxcopy
Re: Insert keystroke into executed batch command
Yeah, the "echo.y|xxcopy" won't work.
The "echo." simulates a carriage return for DOS apps only. Since xxcopy is a separate application the batch file passes stdin control to the external application and simply waits for that app to complete and for stdin to be returned to the batch process.
The only way to manage this would be to embed the batch commands into JS or VBS scripts which act as a wrapper to the external application. As a wrapper, the scripts have the ability to simulate user keystrokes that can be passed into the external application or capture output of the application. And if you are embedding batch commands into JS or VBS...then why even use batch commands at all.
Solution: the latest version of xxcopy 3.08.0 has a fix for the problem that was causing the Splash Warning screen. The reason the Warning screen was popping up at all was because Windows Automatic Updates changes/updates the date stamp of specific files that xxcopy looks for during its OS Compatibility tests. If the dates of files xxcopy is looking for are newer than what xxcopy expects them to be then it triggers the Splash Warning screen. Which means in the next one or two Windows Update patches....one of those 'specific' files could be updated again thus causing the xxcopy splash/warning screen to get triggered. The fix they implemented was simply to update the 'dates' it was comparing against.
Frankly, checking dates of files is a pretty poor way of checking OS compatibility and they should simply fix that process altogether.
The "echo." simulates a carriage return for DOS apps only. Since xxcopy is a separate application the batch file passes stdin control to the external application and simply waits for that app to complete and for stdin to be returned to the batch process.
The only way to manage this would be to embed the batch commands into JS or VBS scripts which act as a wrapper to the external application. As a wrapper, the scripts have the ability to simulate user keystrokes that can be passed into the external application or capture output of the application. And if you are embedding batch commands into JS or VBS...then why even use batch commands at all.
Solution: the latest version of xxcopy 3.08.0 has a fix for the problem that was causing the Splash Warning screen. The reason the Warning screen was popping up at all was because Windows Automatic Updates changes/updates the date stamp of specific files that xxcopy looks for during its OS Compatibility tests. If the dates of files xxcopy is looking for are newer than what xxcopy expects them to be then it triggers the Splash Warning screen. Which means in the next one or two Windows Update patches....one of those 'specific' files could be updated again thus causing the xxcopy splash/warning screen to get triggered. The fix they implemented was simply to update the 'dates' it was comparing against.
Frankly, checking dates of files is a pretty poor way of checking OS compatibility and they should simply fix that process altogether.
-
- Expert
- Posts: 391
- Joined: 19 Mar 2009 08:47
- Location: Iowa
Re: Insert keystroke into executed batch command
Well -- I shouldn't post what I don't know about, I guess. I don't know anything about xxcopy.