c - Set Path Variable Permanently Using ShellExecuteEx -
i come code. execute correctly , return true. doesn't change path variable's value. when type --> setx path "c:\program files\java\jdk1.7.0_02\bin\" in cmd, works , change path value
here code
// prepare shellexecutinfo shellexecuteinfo shrun = {0}; shrun.cbsize = sizeof(shellexecuteinfo); shrun.fmask = see_mask_nocloseprocess; shrun.hwnd = null; shrun.lpverb =null; shrun.lpfile = "c:\\windows\\system32\\setx.exe"; shrun.lpparameters = "path \"\"\"c:\\program files\\java\\jdk1.7.0_02\\bin\\\"\"\""; shrun.lpdirectory =null; shrun.nshow = sw_shownormal; shrun.hinstapp = null; // execute file parameters if(shellexecuteex(&shrun)) printf("done"); else printf("no");
what problem here??
your quoting on arguments wrong. have many quotes. need write
shrun.lpparameters = "path \"c:\\program files\\java\\jdk1.7.0_02\\bin\\\"";
to see version fail did following experiment @ console:
c:\users\heff>setx path """c:\program files\java\jdk1.7.0_02\bin\""" error: invalid syntax. default option not allowed more '2' time(s). type "setx /?" usage.
i note using see_mask_nocloseprocess
. can wait on process handle returned. don't appear doing that. what's more, don't appear closing process handle responsibility when use see_mask_nocloseprocess
.
Comments
Post a Comment