c# - Access is denied (Running a .bat file) -


this code build .bat file , run it.

stringbuilder batch = new stringbuilder(); batch.appendline("@echo off"); batch.appendline("taskkill /im " + process.getcurrentprocess().processname + ".exe /f"); batch.appendline("ping localhost > nul"); batch.appendline("del /f " +  (char)34 + application.executablepath + (char)34); batch.appendline("ren " + (char)34 + application.startuppath + @"\update.exe" + (char)34 + " " + process.getcurrentprocess().processname); batch.appendline((char)34 + application.executablepath + (char)34); batch.appendline("del %0");  file.writealltext(application.startuppath + @"\update.bat", batch.tostring(), encoding.default);         process.start(application.startuppath + @"\update.bat"); 

however, access denied, have run admin, how can it?

not answer question, think not approaching best direction. instead see question provides robust answer trying do: what-is-the-best-way-to-auto-update-a-windows-application

tl;dr if original installation "all users" have problems having manually elevate permissions. installation "per user" simplifies permissions issue.


Comments

Popular posts from this blog

Issues changing the value of an element in an array in matlab -

php - MySQLi binding parameters in a prepared statement doesn't work unless inserted after "WHERE" -

vb.net - Alternative to the T-SQL AS keyword -