Java create bat file and escape spaces -
my app creating .bat
file in users startup
directory able auto run when users logs in.
this how creating .bat
:
file startupfile=getstartupfile(); printwriter out=new printwriter(new filewriter(startupfile)); out.println("@echo off"); out.println("start " + system.getproperty("user.dir") + fileseparator +"myapp.exe"); out.println("exit"); out.close(); }
btw: startupfile
location startup
directory
the problem seems system.getproperty("user.dir")
contains spaces in path. example second line can be:
start c:\program files (x86)\myapp\myapp.exe
and breaks .bat
file when tries find application run.
any ideas how can make .bat
understand find application? no matter been installed?
quoting file location in every case (with or without space) should work
out.println("start \"" + system.getproperty("user.dir") + fileseparator +"myapp.exe\"");
Comments
Post a Comment