Alright, I've spent a few hours bumming around forums and google trying to write this script but I think I'm too much of a noob or doing something too abnormal to Frankenstein my code.
I'm trying to run and executable that scans other files and gives me feedback and prompts. Manually you run this in the command prompt, it does an initial scan, asks what you want to do, you run a repair (could take 5+ min) and then it prompts to run again or close.
Pseudo Code should be:
- Run EXE ArchiveFile ConfigFile
- Wait for "Enter a command>"
- Type 1
- Wait for "Enter a command>"
- Type 7
- Wait for "Enter the print destination>"
- Type 2
- Wait for "Enter a command>"
- Type 9
- Done
Here is my actual code
'Cycle through each iha file in the chosen folder
for each objFile in objFSO.GetFolder(archiveFolder).files
If LCase(objFSO.GetExtensionName(objFile.Name)) = "iha" Then
'run the iharchiveInfo.exe with the chosen config and the current archive
msgbox(chr(34) & exeFile & chr(34) & " " & chr(34) & objfile.path & chr(34) & " " & chr(34) & ArchiveConfig & chr(34) )
set oExec = Shell.exec("cmd.exe /k "& chr(34) & exeFile & " " & chr(34) & objfile.path & chr(34) & " " & chr(34) & ArchiveConfig)
do while Not oExec.StdOut.AtEndOfStream
MsgBox oExec.stdout.Readline
Loop
Msgbox("second line")
oExec.stdin.write chr(34) & exeFile & " " & chr(34) & objfile.path & chr(34) & " " & chr(34) & ArchiveConfig
Do While oExec.Status = 0
WScript.Sleep 100
WScript.StdOut.Write(oExec.StdOut.ReadAll())
WScript.StdErr.Write(oExec.StdErr.ReadAll())
Loop
msgbox ("write")
oExec.stdin.write 1
do while Not oExec.StdOut.AtEndOfStream
MsgBox oExec.stdOut.Readline
Loop
oExec.stdin.write 7
exit for
end if
next
It opens cmd prompt but I never get a msgbox with the Readline. Instead, when I close the cmd prompt I then get msgbox Write.