Hi, I have a batch file that runs a .exe with a command line parameter. When I double-click the .bat file, it runs fine and the .exe generates the correct log file in the correct directory. However, when I use code like this:
or code like this:
The result is that the .bat file says it can't find the .exe file. This ONLY happens when I try to run the batch file from VB. I can run it manually and the batch file works perfectly.
The batch file looks like this:
echo off
if exist log.exe echo "It exists!"
if not exist log.exe echo "I can't find it!"
start log.exe /log-file=..\Logs\testlog.txt
pause
When I run the batch file manually I see "It exists!" and the log file is generated. When I run it via VB code I get "I can't find it!" and an error about the system not finding the file. Any ideas what might be happening?
VB.NET:
Dim p As New Process
p.StartInfo.FileName = Chr(34) & Directory.GetCurrentDirectory() & "\test.bat" & Chr(34)
p.StartInfo.UseShellExecute = True
p.Start()
VB.NET:
Shell(Chr(34) & Directory.GetCurrentDirectory() & "\test.bat" & Chr(34))
The result is that the .bat file says it can't find the .exe file. This ONLY happens when I try to run the batch file from VB. I can run it manually and the batch file works perfectly.
The batch file looks like this:
echo off
if exist log.exe echo "It exists!"
if not exist log.exe echo "I can't find it!"
start log.exe /log-file=..\Logs\testlog.txt
pause
When I run the batch file manually I see "It exists!" and the log file is generated. When I run it via VB code I get "I can't find it!" and an error about the system not finding the file. Any ideas what might be happening?