java - How to run program from %PATH% instead of current folder -
if run program exists in %path% in windows when there program same name in current folder select 1 in current folder instead. there way prevent (to disregard current folder)?
the reason question have java program have placed in run-key in registry this:
[hkey_local_machine\software\microsoft\windows\currentversion\run] myprogram = javaw -cp myprogram.jar com.mycompany.myprogram
the problem on 1 computer tested on didn't work. complained wrong jre version (1.7 instead of 1.8). found on computer installed jre 1.8 on 1.7, 1.7 files still left in windows\system32.
if launch javaw -cp myprogram.jar com.mycompany.myprogram manually in command prompt works, unless have windows\system32 current folder.
the problem when windows starts programs during startup (from run-key in registry) has system32 current folder , therefore use wrong jre-version.
i can fix on specific computer removing incorrect exe-files system32, want work when else installs somewhere else, , best way have come think of forcing windows use %path%, don't know how.
@echo off set "to_run=javaw.exe" %%# in ("%to_run%") set "ppath=%%~$path:#" echo %ppath% "%ppath%" -cp myprogram.jar com.mycompany.myprogram
for more info %~$path:
syntax check for /?
Comments
Post a Comment