locked
Problems with vbs file running a jar file RRS feed

  • Question

  • In order to run a jar server file without a visible cmd window, I use this vbs 

    scriptSet WshShell = CreateObject("WScript.Shell")
    WshShell.Run chr(34) & "C:\Users\Server\Test\Run.bat" & Chr(34), 0
    Set WshShell = Nothing

    This code has confirmed working on two others win7 computers. There in no cmd window visible, clients can connect to the server, and I have confirmed java.exe running as a process in task manager.  However on my new computer which is about 5 days old(fresh win7 Home Premium install), this script fails to start the jar file.  The Run.bat starts the jar fine, but with a cmd window. When the vbs script is run, task manager registers cmd.exe and conhost.exe but will not progress to start java.exe. Cmd.exe and conhost.exe remains open until I manually end them. I have installed both java 32 and 64 bit and tried script with both  but received same result as listed above. I have also used the same vbs script on same problematic computer to start another .bat, that runs a non-jar file, and it works fine with no permanent cmd window.  Please help me, I have no idea what is wrong.


    • Edited by Winthryth Friday, May 2, 2014 1:57 AM
    Friday, May 2, 2014 1:55 AM

Answers

  • I do not recommend calling run() without setting bWaitOnReturn as "TRUE" your deployment could reboot the machine while java installation is still in progress in the background. Additionally, I would also prefix the command interpreter to the command line:

    CreateObject("Wscript.Shell").Run "cmd.exe /c ""c:\users\server\test\run.bat""", 0, true

    Otherwise, the problem could be *anything* run.bat is a black box, and I can't tell what it is doing wrong.

    The best thing to do is to add some debugging to your script. A simple line like:

    @echo script [%~f0] now starting >> %temp%\%~n0.log

    [...]

    @echo script [%~f0] now finished >> %temp%\%~n0.log

    At the start/end of your script can help you *verify* that your vbscript correctly passed control to the *.cmd script and you *.cmd script correctly passed control back to the vbscript. If you see both start/finished entries, then the problem is within your script, otherwise you did not call the command correctly.

    Keith Garner - keithga.wordpress.com

    Monday, May 5, 2014 6:17 PM

All replies

  • I do not recommend calling run() without setting bWaitOnReturn as "TRUE" your deployment could reboot the machine while java installation is still in progress in the background. Additionally, I would also prefix the command interpreter to the command line:

    CreateObject("Wscript.Shell").Run "cmd.exe /c ""c:\users\server\test\run.bat""", 0, true

    Otherwise, the problem could be *anything* run.bat is a black box, and I can't tell what it is doing wrong.

    The best thing to do is to add some debugging to your script. A simple line like:

    @echo script [%~f0] now starting >> %temp%\%~n0.log

    [...]

    @echo script [%~f0] now finished >> %temp%\%~n0.log

    At the start/end of your script can help you *verify* that your vbscript correctly passed control to the *.cmd script and you *.cmd script correctly passed control back to the vbscript. If you see both start/finished entries, then the problem is within your script, otherwise you did not call the command correctly.

    Keith Garner - keithga.wordpress.com

    Monday, May 5, 2014 6:17 PM
  • I toke your advice and revised the vbs script and added the log creating command. It reads

    script [C:\VM\Share\bukkit\Run.bat] now starting script [C:\VM\Share\bukkit\Run.bat] now starting

    after a single run of the vbs script.

    There is no end entry but that may be because it is a server and since no clients can connect to it, a stop command can't be sent. Still no java.exe is detected in task manager.  However with the addition of the log command, cmd.exe and conhost.exe only stay up in task manager briefly and then end. The path to the file only changed because I though it might have been a permission issue but it is not.


    • Edited by Winthryth Tuesday, May 6, 2014 8:20 PM
    Tuesday, May 6, 2014 8:19 PM