Reputation: 1361
I had been able to start this program previously with the following code:
dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
strCmd = "cmd.exe /c start /D C:\Jts C:\Windows\system32\javaw.exe -cp jts.jar;total.2012.jar -Dsun.java2d.noddraw=true -Dswing.boldMetal=false -Dsun.locale.formatasdefault=true -Xmx768M -XX:MaxPermSize=128M jclient/LoginFrame C:\Jts"
WshShell.Run(strCmd)
Now, however, thanks to a wonderful java
update, my java.exe
file is located here:
C:\Program Files (x86)\Java\jre1.8.0_31\bin\javaw.exe
I am having trouble replacing the strCmd
variable above so that my VBScript
doesn't error out. I know it has to do with the spacing in Program Files (x86)
and i have tried to implement this answer: How to use spaces in CMD?
but it doesn't seem to be working. Please help and explain what these spaces do please.
EDIT:
I just figured it out. God, I hate spaces. Apparently this worked, I would like to know if this is the best solution or not:
strCmd = "cmd.exe /c start /D C:\Jts C:\""Program Files (x86)""\Java\jre1.8.0_31\bin\javaw.exe -cp jts.jar;total.2012.jar -Dsun.java2d.noddraw=true -Dswing.boldMetal=false -Dsun.locale.formatasdefault=true -Xmx768M -XX:MaxPermSize=128M jclient/LoginFrame C:\Jts"
Upvotes: 0
Views: 844
Reputation: 46
The first set of parameters in quotes for the Start command is assumed to be the windows title.
Your command does not work, it may appear to but that's because it's so wrong Windows can't tell how wrong it and treats it as a partial path..
JavaW would be listed under app paths. You are specifing your folder as a window title, leaving the program name isolated (but Windows knows how to find GUI programs just by name).
dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "cmd.exe /c start """" /D C:\Jts ""C:\Windows\system32\javaw.exe"" -cp jts.jar;total.2012.jar -Dsun.java2d.noddraw=true -Dswing.boldMetal=false -Dsun.locale.formatasdefault=true -Xmx768M -XX:MaxPermSize=128M jclient/LoginFrame C:\Jts"
Fixed needless obfuscation and pointless variable generation.
Removed brackets from Run (you aren't testing the return value).
Put in a set of blank quotes for Windows Title ("""")
Quoted JavaW path (doesn't need it for System32). Remember if quotes are used anywhere for Start the first set MUST be windowtitle.
Upvotes: 1