I'm developing on a server using windows 2008. My c# application launches sub processes with different user credentials , after which it checks the file ownership of the created files.
Due to the following issue, I was forced to turn off the UAC on the system (: http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/c449f0c2-65c3-4083-9279-e3b9a9d099d2/)
While this resolved the process.hasExited() issue, I ran into a problem concerning file ownership. With the UAC turned off, windows is unable/unwilling to display the user as owner of the created files, instead referring to the group to which it belongs.
Is there a workaround for this problem?
I know disabling UAC isn't "good practice", but some problems just persevered...
Hmmm, a sub process was created from one parent process, and the UAC setting will be the same with the parent process. So one solution: elevate the server process, "Run as Admin" or embed the manifest into the server process - http://msdn.microsoft.com/en-us/library/bb756929.aspx
Another solution, use ShellExecute with the verb = "runas" http://msdn.microsoft.com/en-us/library/bb762153(VS.85).aspx or in C#: ProcessStartInfo.Verb = "runas".
And if you want to launch an un-elevated application from an elevated process, please refer to this FAQ: http://social.msdn.microsoft.com/Forums/en-US/windowscompatibility/thread/7d585c05-0b61-45e7-b554-740382ffb7cc#FAQ31