none
Starting a .JS File

    Question

  • Hello i am trying to run a .js file in VB.Net and its just not launching.

    Im able to launch a .exe using the same code but whenever i put .js it just doesnt work.

     System.Diagnostics.Process.Start(appData & "\" & "MOD_Minecraft" & "\" & "runjs.js")
    
    

    ive also tried 

    Process.Start

    and 

    Diagnostics.Process.Start

    Thursday, August 15, 2013 10:22 AM

Answers

  • A js file is not an executable file (.exe, .com, .dll).  It runs using an application.  The process function doesn't search the environmental variables "PATH" so you also need to include full path or the excutable and the file you are using.

    What applicastion automaticall starts when you run a JS (this will vary depending on the applications installed on the PC).

    Here are some ways of getting applications to run uisng the process function

    1) Make sure you inlcude full path of executables

    2) Run under c:\windows\system32\cmd.exe and put the file a a command line option

    3) Run with the application as the process name.  Check the application command line options and the make your filename (use full path name) as part of the command line options.


    jdweng

    Friday, August 16, 2013 3:57 AM
  • If you have something set up to open JS files when you click on them, you can have your program launch the files with this program automatically.  The key here is "UseShellExecute = true".  This tells process.start to use whatever program is associated with the file type started.

    NOTE:  This example comes from the link at the bottom of my post. (replace "C:\data\ct.txt" with the path to your js file)

    Dim p As New System.Diagnostics.Process
    Dim s As New System.Diagnostics.ProcessStartInfo("C:\data\ct.txt")
    s.UseShellExecute = True
    s.WindowStyle = ProcessWindowStyle.Normal
    p.StartInfo = s
    p.Start()

    Link: http://bytes.com/topic/visual-basic-net/answers/353534-how-open-file-its-default-program

    Friday, August 16, 2013 8:44 PM

All replies

  • Im still looking for a solution =(
    Friday, August 16, 2013 2:03 AM
  • A js file is not an executable file (.exe, .com, .dll).  It runs using an application.  The process function doesn't search the environmental variables "PATH" so you also need to include full path or the excutable and the file you are using.

    What applicastion automaticall starts when you run a JS (this will vary depending on the applications installed on the PC).

    Here are some ways of getting applications to run uisng the process function

    1) Make sure you inlcude full path of executables

    2) Run under c:\windows\system32\cmd.exe and put the file a a command line option

    3) Run with the application as the process name.  Check the application command line options and the make your filename (use full path name) as part of the command line options.


    jdweng

    Friday, August 16, 2013 3:57 AM
  • from http://www.scriptingmaster.com/javascript/running-javascript.asp

    "The browser is responsible for running JavaScript. Thus the output from JavaScript is going to be more responsive as the data does not need to travel to or from server. A web browser runs JavaScript when a web page is downloaded or in response to an event."

    Friday, August 16, 2013 3:58 AM
  • I'm still looking for a reply =(

    Friday, August 16, 2013 4:30 PM
  • If you have something set up to open JS files when you click on them, you can have your program launch the files with this program automatically.  The key here is "UseShellExecute = true".  This tells process.start to use whatever program is associated with the file type started.

    NOTE:  This example comes from the link at the bottom of my post. (replace "C:\data\ct.txt" with the path to your js file)

    Dim p As New System.Diagnostics.Process
    Dim s As New System.Diagnostics.ProcessStartInfo("C:\data\ct.txt")
    s.UseShellExecute = True
    s.WindowStyle = ProcessWindowStyle.Normal
    p.StartInfo = s
    p.Start()

    Link: http://bytes.com/topic/visual-basic-net/answers/353534-how-open-file-its-default-program

    Friday, August 16, 2013 8:44 PM