-2

I have a jar file that I would like to run using VBScript. But I don't want to leave the command prompt open while the application is running.

Currently, I can achieve this by putting the java command in a BAT file as follows:

java -Xms256M -Xmx1024M -jar myApp.jar

I then have a VBScript that would call the BAT file as follows:

Set WshShell = CreateObject("WScript.Shell") 
WshShell.Run chr(34) & "myApp.bat" & Chr(34), 0
Set WshShell = Nothing

But I think that using a VBScript to call a BAT file to invoke the java command is unnecessary. To optimize, I wanted the VBScript to invoke the java command directly so that I can disregard the BAT file.

I tried replacing the VBScript into something like the following:

Set WshShell = CreateObject("WScript.Shell")
WshShell.Run chr(34) & "java -Xms256M -Xmx1024M -jar myApp.jar" & Chr(34), 0
Set WshShell = Nothing

But the following error occurs:

Error: The system cannot find the file specified.
Code: 80070002

Any ideas?

RanRan
  • 9
  • 3

1 Answers1

-1

Change "java" to absolute path such as "C:\Program Files\jdkXXX\bin\java.exe"

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
Wilson.F
  • 49
  • 3
  • Since this will be used by several users, is there anyway that the script to search the actual location of the java.exe? – RanRan Oct 22 '20 at 09:22