write to a log file while running program as a normal user (log file created while running as administrator)


i wrote application called scheduled batch file.

i else in batch file requires administrator rights have run administrator.  the log file first created when running administrator.

now want run application normal user.  the issue writing log file fails because not have permissions it.

this program run on multiple machines, while can manually change permissions of log file on dev machine, annoying manually everywhere.  any ideas programatically?

i remember doing quick , dirty once before hardcoded username , domain wanted grant permission to.

hi friend,

do mean you want to run batch file administrator or application? if batch file, please try following code.

in c#: =====================================================
try  {  processstartinfo procinfo = new processstartinfo();  procinfo.useshellexecute = true;  procinfo.filename = @"cmd.bat";  //the file in dir.  procinfo.workingdirectory = @""; //the working dir.  procinfo.verb = "runas";  process.start(procinfo);  //start process.  }  catch (exception ex)  {  messagebox.show(ex.message.tostring());  }     

if application,there many articles on web explaining uac , how programs interact using manifest files. following msdn link talks manifest syntax : http://msdn.microsoft.com/en-us/library/bb756929.aspx        

http://stackoverflow.com/questions/2818179/how-to-force-my-net-app-to-run-as-administrator-on-windows-7

have nice day~


we trying better understand customer views on social support experience, participation in interview project appreciated if have time. helping make community forums great place.
click here participate survey.



Visual Studio Languages  ,  .NET Framework  >  Visual C#



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

job syspolicy_purge_history job fail in sqlserver 2008

Trying to register with public marketplace error with 'Get-AzureStackStampInformation'