Batch file problem
-
I don't get this at all. Here's the deal: I have a TextBox. Its properties are: Text:
C:\
Name:TextBox1
Next to the TextBox, i have a button. This is the code under the click event:Process.Start(TextBox1.Text & "\test.bat")
So when you click the button, the app should run the filetest.bat
that has been placed in the directory written in the TextBox,C:\
in this case. The problem is that the batch doesn't run fromC:\
, but fromC:\Documents and Settings\Atom\Mijn documenten\Visual Studio 2005\Projects\Test_App\bin\Debug
Thats the folder where the debug .exe is located. Why is it running fromC:\Documents and Settings\Atom\Mijn documenten\Visual Studio 2005\Projects\Test_App\bin\Debug
instead ofC:\
? I need it to run fromC:\
Any ideas? -
I don't get this at all. Here's the deal: I have a TextBox. Its properties are: Text:
C:\
Name:TextBox1
Next to the TextBox, i have a button. This is the code under the click event:Process.Start(TextBox1.Text & "\test.bat")
So when you click the button, the app should run the filetest.bat
that has been placed in the directory written in the TextBox,C:\
in this case. The problem is that the batch doesn't run fromC:\
, but fromC:\Documents and Settings\Atom\Mijn documenten\Visual Studio 2005\Projects\Test_App\bin\Debug
Thats the folder where the debug .exe is located. Why is it running fromC:\Documents and Settings\Atom\Mijn documenten\Visual Studio 2005\Projects\Test_App\bin\Debug
instead ofC:\
? I need it to run fromC:\
Any ideas? -
I don't get this at all. Here's the deal: I have a TextBox. Its properties are: Text:
C:\
Name:TextBox1
Next to the TextBox, i have a button. This is the code under the click event:Process.Start(TextBox1.Text & "\test.bat")
So when you click the button, the app should run the filetest.bat
that has been placed in the directory written in the TextBox,C:\
in this case. The problem is that the batch doesn't run fromC:\
, but fromC:\Documents and Settings\Atom\Mijn documenten\Visual Studio 2005\Projects\Test_App\bin\Debug
Thats the folder where the debug .exe is located. Why is it running fromC:\Documents and Settings\Atom\Mijn documenten\Visual Studio 2005\Projects\Test_App\bin\Debug
instead ofC:\
? I need it to run fromC:\
Any ideas?Just to clarify, is it running c:\test.bat, but performing tasks on the debug folder? or is test.bat not running at all?
topcoderjax - Remember, Google is your friend. Try this Custom Google Code Search
-
I don't get this at all. Here's the deal: I have a TextBox. Its properties are: Text:
C:\
Name:TextBox1
Next to the TextBox, i have a button. This is the code under the click event:Process.Start(TextBox1.Text & "\test.bat")
So when you click the button, the app should run the filetest.bat
that has been placed in the directory written in the TextBox,C:\
in this case. The problem is that the batch doesn't run fromC:\
, but fromC:\Documents and Settings\Atom\Mijn documenten\Visual Studio 2005\Projects\Test_App\bin\Debug
Thats the folder where the debug .exe is located. Why is it running fromC:\Documents and Settings\Atom\Mijn documenten\Visual Studio 2005\Projects\Test_App\bin\Debug
instead ofC:\
? I need it to run fromC:\
Any ideas?I think you will be interested in ProcessStartInfo.WorkingDirectory groeten
Luc Pattyn
try { [Search CP Articles] [Search CP Forums] [Forum Guidelines] [My Articles] } catch { [Google] }
-
I don't get this at all. Here's the deal: I have a TextBox. Its properties are: Text:
C:\
Name:TextBox1
Next to the TextBox, i have a button. This is the code under the click event:Process.Start(TextBox1.Text & "\test.bat")
So when you click the button, the app should run the filetest.bat
that has been placed in the directory written in the TextBox,C:\
in this case. The problem is that the batch doesn't run fromC:\
, but fromC:\Documents and Settings\Atom\Mijn documenten\Visual Studio 2005\Projects\Test_App\bin\Debug
Thats the folder where the debug .exe is located. Why is it running fromC:\Documents and Settings\Atom\Mijn documenten\Visual Studio 2005\Projects\Test_App\bin\Debug
instead ofC:\
? I need it to run fromC:\
Any ideas?First, the command line that you're actually running is
C:\\test.bat
. The two backslashes next to each other work, but could cause you problems later if used indiscriminatly. Second, the working directory is the directory from where your code is launched. Like Luc said, you have to set the WorkingDirectory[^] property of the ProcessStartInfo object.Dim psi As New ProcessStartInfo(Path.Combine(TextBox1.Text, "test.bat")) psi.WorkingDirectory = TextBox1.Text Process.Start(psi)
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007 -
First, the command line that you're actually running is
C:\\test.bat
. The two backslashes next to each other work, but could cause you problems later if used indiscriminatly. Second, the working directory is the directory from where your code is launched. Like Luc said, you have to set the WorkingDirectory[^] property of the ProcessStartInfo object.Dim psi As New ProcessStartInfo(Path.Combine(TextBox1.Text, "test.bat")) psi.WorkingDirectory = TextBox1.Text Process.Start(psi)
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007kubben, i removed one of the \ but that didn't fix it. Its still running from the debug folder. quote: Just to clarify, is it running c:\test.bat, but performing tasks on the debug folder? Thats right. Its running from the debug folder, i want it to run from C:\ Luc and Dave, that did it! :D Thanks to all of you for your quick answers. :)