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

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -