java - Replacing programs with batch issue -


i want create auto-updater of program.
in java part looks like

int pid = kernel32.instance.getcurrentprocessid();                     string cmd = folder + "update.bat" + " " + currentloc  + " " + updateloc +  " " + integer.tostring(pid); runtime.getruntime().exec(cmd); 

and batch contains

set "name=gamedrive logs viewer.exe" set "myname=update.bat" taskkill /pid %3 taskkill /pid %3 del "%1\%name%" move "%2\%name%" "%1" "%1\%name%" del "%2\%myname%" 

so, i'm killing current program , delete it.
move new version old folder, run new version, , delete bat file.
bat file works when call cmd sending parameters.
nothing happend when i'm trying use java program.
found, dialog windows creating current program have same processid. (i tested bat).
so, guess batch called java program same processid , kill himself.
right? , if yes - can how that?

i guess need launch update.bat in cmd instance follows (add path necessary). in java use updatecall.bat next content:

either cmd.exe: start new cmd shell , (optionally) run command/executable program.

cmd /c ""update.bat" %*" 

or start: start program, command or batch script (opens in new window.)

start "" "update.bat" %*  

if started batch file command processor run /k switch cmd.exe. means window tend remain after batch has been run. auto close it, add exit command end of started batch.

i'm sure there smarter solution without auxiliary batch...


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -