Search code examples
vb.netfilebatch-fileprocessstartup

VB.net, my code unable to run bat file


Dim app As String = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
    If System.IO.Directory.Exists(app & "\Divers") Then
        Try
            Process.Start(app & "\Divers\b.bat")
            cs.Text = "OK"
            cs.Refresh()
        Catch ex As Exception
            eror.Text = "(B) Problems"
            cs.Text = "error"
        End Try
        Try
            Process.Start(app & "\Divers\Realtek\diver.exe")
            d.Text = "OK"
        Catch ex As Exception
            DebugLog()
            error.Text = "Driver Problems"
            cs.Text = "error"
        End Try
        Try
            Process.Start(app & "\Divers\a.bat")
            CVS.Text = "OK"
        Catch ex As Exception
            error.Text = eror.Text & "(A) Problems"
            cs.Text = "error"
        End Try

And that is my code guys but the bat file is not working. Is opened but do nothing, if i open the bat file manual (with a mouse and double click logic!!!) its working. Please help


Solution

  • Your batch file may be working based on a working directory, and because you run the batch file with software that is in a different folder, the batch file's working directory does not match.

    Put your software in the batch file folder and try again.