Have a look at my batch file below. As you can see, I'm a pretty novice scripter. But, here is what I'm trying to accomplish.
Create a TEMP folder to copy another folder and its contents from a server to another server. Then copy folder contents, that much works. But the START of the first .exe provides me a need to answer 2 question. They need to be answered as a keypress of 1, and the second question needs a 0 to be entered, then the AppRemover6.exe will run. I've tried to use echo but I'm missing something or syntax is incorrect.
I also want the first exe to finish completely before going to the next exe.
As for the reg file, a windows pop-up needs to be answered automatically with an answer (mouse click) of YES to make the registry change.
@ECHO OFF
MD -P C:\TEMP
XCOPY "\\mybigserver\Apps\AppCleanerUtils" C:\TEMP /E /I
START /D "C:\TEMP\AppCleanerUtil6" AppRemover6.exe
START /D "C:\TEMP\AppCleanerUtil6" PatchRegistry.reg
START /D "C:\TEMP\C:\TEMP\AppCleanerUtil5" AppRemover5.exe
RMDIR /S /Q "C:\TEMP\AppCleanerUtil6"
RMDIR /S /Q "C:\TEMP\AppCleanerUtil5"
If there is a better way to do this?
many questions so for first finish before start next use:
START /WAIT ...
for passing parameters to your app try advice of empty argument "" from here: Using the "start" command with parameters passed to the started program
There is no -P
switch on the MD
command. Even if there were, it is not needed. Windows already has a TEMP
variable that should be used.
If the AppRemover6.exe
program does not read from stdin, then redirecting a file to it will not work. Does AppRemove6.exe
have any command line parameters that would tell it to read input from a file?
Try getting it to work directly from the cmd prompt. Create a file with the two items that must be entered.
=== response.txt
0
1
AppRemover6.exe <response.txt
If it were me, I would make these changes.
@ECHO OFF
XCOPY "\\mybigserver\Apps\AppCleanerUtils" "%TEMP%" /E /I
START /WAIT /D "%TEMP%\AppCleanerUtil6" AppRemover6.exe
START /D "%TEMP%\AppCleanerUtil6" PatchRegistry.reg
START /D "%TEMP%\C:\TEMP\AppCleanerUtil5" AppRemover5.exe
RMDIR /S /Q "%TEMP%\AppCleanerUtil6"
RMDIR /S /Q "%TEMP%\AppCleanerUtil5"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.