Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Batch file problem

Batch file problem

Scheduled Pinned Locked Moved Visual Basic
csharpvisual-studiodebugginghelpquestion
6 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    The Mighty Atom
    wrote on last edited by
    #1

    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 file test.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 from C:\, but from C:\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 from C:\Documents and Settings\Atom\Mijn documenten\Visual Studio 2005\Projects\Test_App\bin\Debug instead of C:\? I need it to run from C:\ Any ideas?

    K D L D 4 Replies Last reply
    0
    • T The Mighty Atom

      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 file test.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 from C:\, but from C:\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 from C:\Documents and Settings\Atom\Mijn documenten\Visual Studio 2005\Projects\Test_App\bin\Debug instead of C:\? I need it to run from C:\ Any ideas?

      K Offline
      K Offline
      kubben
      wrote on last edited by
      #2

      This is just a guess, but it looks like you are pointing to: c:\\test.bat instead of c:\test.bat I would remove one of the \ Hope that helps. Ben

      1 Reply Last reply
      0
      • T The Mighty Atom

        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 file test.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 from C:\, but from C:\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 from C:\Documents and Settings\Atom\Mijn documenten\Visual Studio 2005\Projects\Test_App\bin\Debug instead of C:\? I need it to run from C:\ Any ideas?

        D Offline
        D Offline
        Dave Herren
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • T The Mighty Atom

          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 file test.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 from C:\, but from C:\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 from C:\Documents and Settings\Atom\Mijn documenten\Visual Studio 2005\Projects\Test_App\bin\Debug instead of C:\? I need it to run from C:\ Any ideas?

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          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] }


          1 Reply Last reply
          0
          • T The Mighty Atom

            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 file test.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 from C:\, but from C:\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 from C:\Documents and Settings\Atom\Mijn documenten\Visual Studio 2005\Projects\Test_App\bin\Debug instead of C:\? I need it to run from C:\ Any ideas?

            D Offline
            D Offline
            Dave Kreskowiak
            wrote on last edited by
            #5

            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

            T 1 Reply Last reply
            0
            • D Dave Kreskowiak

              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

              T Offline
              T Offline
              The Mighty Atom
              wrote on last edited by
              #6

              kubben, 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. :)

              http://www.themightyatom.nl

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups