Execute a .bat file from VBScript

ModioHomeBasic Jul 25, 2012

  1. Mo

    ModioHomeBasic Newbie
    0/47

    Joined:
    Feb 25, 2011
    Messages:
    22
    Likes Received:
    3
    Trophy Points:
    0
    Gender:
    Male
    Location:
    United Kingdom
    Console:
    Xbox
    I have been searching for over a week for a snip of code that will execute a Batch file in the same way as it would if you clicked on it in the folder.

    Process.Start("file path" & "StartServer1.bat")

    This opens the file and executes the code but because the .bat file doesn't have a strick file location to the .jar so it says, "JAR not found" or "You don't have permition to access this file".

    I have tried numerous different ways to open the file but every time I get an error of some sort. All I need to be able to do is start a server with a .bat file. The .bat is located in a folder on the desktop with the .jar in that folder.

    I am a beginner when it comes to VB.net and the only resources I have is Google and that lot. If anyone can help please let me know.
     
    • Like Like x 1
  2. Ji

    JizzaBeez The One and Only
    0/47

    Joined:
    Nov 15, 2009
    Messages:
    384
    Likes Received:
    129
    Trophy Points:
    0
    Gender:
    Male
    Location:
    Cerebral Cortex.
    Console:
    Xbox
    VB.Net and VBScript are similar but not the same. VB.Net has to be compiled in order to run and VBScript does not.

    VBScript:
    Code:
    Set objShell = WScript.CreateObject("WScript.Shell")
    objShell.Run "notepad.exe"
    
    VB.Net:
    Code:
    ' method 1
    Dim p As Process = Process.Start("notepad.exe")
    
    ' method 2
    Dim pID As Integer = Shell("notepad.exe")
    
     

Share This Page

Close