Redirection Symbol Not Working
Keywords: redirection /c command.com
You can't use a Run command like:
Run("mem.exe", "> mem.txt")Windows limitation. Instead, use:
Run("command.com", "/c mem >mem.txt")(Note: NO SPACE after the >) ; /C closes automatically.(/K = execute following string and then leave DOS window open.)
You need to set the command.com shortcut (or a copy of it that you run instead of command.com (and its a PIF file - look at it in DOS)) to "CLOSE WINDOW ON EXIT" and "RUN AS A WINDOW".
You can get a list of the inventory of a hard drive and send it to a text file by using the following line:
RunWait("command.com","/c dir c:\ /s > c:\hd.txt")Hd.txt is the file the info is being sent to.
Question:
I am trying to run an .EXE for a totally different application. THe syntax is what I got from the vendor documentation. I can run it fine from a DOS window but get this error when trying to run the batch file from Winbatch:Error 3068: function syntax, illegal delimiter found.I have no control over the < required for this .EXE. as follows"ppadmtool.exe" < enable.txtAnswer:
In that case....DirChange("C:\Desired Start-in Directory") cmd=Environment("COMSPEC") RunWait(cmd,"/c ppadmtool.exe <enable.txt")Note. No space between < and enable.txt
Question:
I am attempting to run a DOS command using the RunWait command with the generic "ANYCMD.BAT" technique. This has worked fine for me in the past, but in this case seems to be having a problem. The command I am trying to execute is as follows:RunWait("ANYCMD.BAT", "net use y: > c:\test.txt")where ANYCMD.BAT contains:%1 %2 %3 %4 %5 %6 %7 %8 %9I have noticed that the redirection character ('>') seems to be the problem here... On WinNT 3.51 the above does not work at all, and on Win95 ANYCMD.BAT only receives the 1st 3 parameters (ie. net use y:) and drops the rest. Any ideas???Answer:
It is not Windows that cannot do redirection, it is the nature of Dos batch files to not be able to do redirection, due to the nature of how Dos batch is incorporated within the Dos shell.Two solutions. Take your choice:
where a simple ANYCMD2.BAT contains something like (or a more detailed BAT file might be necessary, as in the example following this one):
- comspec=Environment("COMSPEC") RunWait(comspec,"/c net use y: > c:\test.txt")
OR
- RunWait("ANYCMD2.bat", "c:\test.txt net use y:")
%2 %3 %4 %5 %6 %7 %8 %9 > %1You might need to change your ANYCMD.BAT to something like the following:
@echo off echo %1 %2 %3 %4 %5 %6 %7 %8 %9|find "}" >nul if errorlevel 1 goto NoRedir :IsRedir If [%1]==[}] Exit :: impossible If [%2]==[}] Goto Do2 If [%3]==[}] Goto Do3 If [%4]==[}] Goto Do4 If [%5]==[}] Goto Do5 If [%6]==[}] Goto Do6 If [%7]==[}] Goto Do7 If [%8]==[}] Goto Do8 If [%9]==[}] Exit :: impossible Exit :: should not happen :Do2 %1 > %3 Exit :Do3 %1 %2> %4 Exit :Do4 %1 %2 %3> %5 Exit :Do5 %1 %2 %3 %4> %6 Exit :Do6 %1 %2 %3 %4 %5> %7 Exit :Do7 %1 %2 %3 %4 %5 %6> %8 Exit :Do8 %1 %2 %3 %4 %5 %6 %7> %9 Exit :NoRedir %1 %2 %3 %4 %5 %6 %7 %8 %9 ExitI've given this initial tests and I believe it should work either as is or with minimal tweaking. One thing you MUST do is substitute "}" for ">" when you call the batch file, and the batch file changes it back to ">".Also, while in Dos you do not need spaces before or after the ">", you must treat "}" as a separate word for this batch file to work.
eg:
RunWait("ANYCMD.BAT","one two three } five")
Article ID: W12898Filename: Slash C and Redirection Symbol Not Working.txt