How do you call an exe from code and get around possible UAC action against this?

天大地大妈咪最大 提交于 2019-12-12 10:21:31

问题


I'm using system.diagnostics.process to start an msi file in quiet mode. I'm getting an exit code 1625, and I suspect its because UAC is preventing it from running. I've turned off the UAC prompts but no dice...

How can I make sure that I'm properly elevating the privileges of the msiexec so it actually runs?

Thanks,

Isaac


回答1:


UAC Elevation in Managed Code: Starting Elevated Processes




回答2:


ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.Arguments = "/i " +  "\""+Directory.GetCurrentDirectory()+"\\"+msiPath +"\"" +" /q";
startInfo.FileName = "msiexec.exe";
startInfo.Verb = "runas";


Process installProcess = Process.Start(startInfo);

Well, this is what I did, and it works.




回答3:


Try running your process with the admin privileges and see if the problem persists



来源:https://stackoverflow.com/questions/4637767/how-do-you-call-an-exe-from-code-and-get-around-possible-uac-action-against-this

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!