I had the same problem a while ago. Wrote 2 batch files and 1 Autoit
script:
- run.bat
- run_with_pause.bat
- run_with_parameters.au3
The first just runs it, the second runs it and stops, the third prompts
for parameters, runs it, then pipes output to a log file. I have links
to all 3 in my Send To folder (compile au3 to exe first). Works ok,
just right click in Explorer window.
Great thread, I'm going to check out the other suggestions,
w4tch3r
Here's the contents of each file:
------------------------------------------------------------------------
Run.Bat:
call %1
------------------------------------------------------------------------
Run_with_pause.bat:
call %1
pause
------------------------------------------------------------------------
Run_with_parameters.au3:
; set log file. currently set to write to the same dir as this script
$logfilepath = @ScriptDir
$logfilename = "Run With Parameters Output.txt"
; check that we have a command line parameter
if $CmdLine[0] = 0 then
msgbox(0, "Error - No Parameters!", "Run With Parameters needs one
command line parameter (the CMD.EXE to be run)")
exit
endif
; get/make progname
$cmdpath = StringSplit($CmdLine[1], "\")
$progname = $cmdpath[$cmdpath[0]]
$progpath = StringTrimRight ( $CmdLine[1], Stringlen($progname))
$logfile = """" & $logfilepath & "\" & $logfilename & """"
RunWait(@ComSpec & " /c echo Timestamp: " & _NowDate() & " " & _NowTime
() & " > " & $logfile, $progpath, @SW_MINIMIZE)
RunWait(@ComSpec & " /c echo Program Name: " & $progname & " >> " &
$logfile, $progpath, @SW_MINIMIZE)
RunWait(@ComSpec & " /c echo Program Path: " & $progpath & " >> " &
$logfile, $progpath, @SW_MINIMIZE)
; ask for parmeters
$params = InputBox($progname & " parameters", "Parameters?", "", "",
400, 100, -1, -1)
if @error then exit
RunWait(@ComSpec & " /c echo User Entered Params: " & $params & " >> "
& $logfile, $progpath, @SW_MINIMIZE)
; generate cmd
$cmd = $progname & " " & $params
RunWait(@ComSpec & " /c echo Command Line: " & $cmd & " >> " &
$logfile, $progpath, @SW_MINIMIZE)
; ask user if generated cmd is ok
;MsgBox(1, "Launch " & $progname & " with:", $cmd)
;if @error then exit
; run command, pipe output to log file
RunWait(@ComSpec & " /c echo
_________________________________________________" & " >> " & $logfile,
$progpath, @SW_MINIMIZE)
RunWait(@ComSpec & " /c echo." & " >> " & $logfile, $progpath,
@SW_MINIMIZE)
RunWait(@ComSpec & " /c echo." & " >> " & $logfile, $progpath,
@SW_MINIMIZE)
RunWait(@ComSpec & " /c " & $cmd & " >> " & $logfile, $progpath,
@SW_MINIMIZE)
RunWait(@ComSpec & " /c echo." & " >> " & $logfile, $progpath,
@SW_MINIMIZE)
RunWait(@ComSpec & " /c echo." & " >> " & $logfile, $progpath,
@SW_MINIMIZE)
RunWait(@ComSpec & " /c echo
_________________________________________________" & " >> " & $logfile,
$progpath, @SW_MINIMIZE)
; open log file
;$editornamepath = "j:\_apps\scite\scite.exe"
;$showlogcmd = """" & $editornamepath & """ " & $logfile
;Runwait($showlogcmd)
$showlogcmd = "type_pause.bat " & """" & $logfilename & """"
RunWait(@ComSpec & " /c " & $showlogcmd, $logfilepath)