View Full Version : Running batch file
Hi,
I am trying to run a batch file during my installation. the batch file should run silently (i don't care if the user sees the screen but shouldn't be able to do anything) recieve "Y", and redirect output to a log file.
this is what i wrote in my code:
File.Run("cmd","echo y | "..InstallPath.."Setup.bat > log.txt", "", SW_SHOWNORMAL, false);
it is not working :(
how should it be done???
thanks,
Dana
TJ_Tigger
07-12-2006, 06:14 AM
File.Run(_SystemFolder .. "cmd.exe","\"echo y | "..InstallPath.."Setup.bat > log.txt\"", "", SW_SHOWNORMAL, false);
the parameters passed to the cmd file may need to be contained in quotes and you may have to point to the full path of the cmd exe.
Tigg
I tried it as you offered, the problem is that the cmd window opens but nothing happens... is there some other way of doing it?
thank you,
Dana
TJ_Tigger
07-12-2006, 08:28 AM
What does the variable InstallPath contain. Maybe you need to add slashes before Setup.bat to have it work.
File.Run(_SystemFolder .. "cmd.exe","\"echo y | "..InstallPath.."\\Setup.bat > log.txt\"", "", SW_SHOWNORMAL, false);
Have you tried to type the command successfully from the Run window. For instance I will run this command from the Start-> Run dialog
cmd /K "ipconfig"
to run this from AMS I would do the following.
File.Run(_SystemFolder .. "cmd.exe","/k \"ipconfig\"", "", SW_SHOWNORMAL, false);
and it works for me. Why not just run the batch file using File.Run with the arguments set to output to a log file?
Tigg
It is running from command line and i do have double slash before the Setup.bat.
in you last suggestion did you mean:
File.Run("\""..InstallPath.."\\Setup.bat\"","> log.txt","",SW_NORMAL,true)
in that case how do i get the "y" input?
thanks again for your help,
Dana
TJ_Tigger
07-12-2006, 08:59 AM
Yeah that is what I was thinking of , have you tried this with the echo after the redirection of output to log.txt?
File.Run("\""..InstallPath.."\\Setup.bat\"","> log.txt | echo y","",SW_NORMAL,true)
Powered by vBulletin™ Version 4.0.6 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.