0

I have a c# app that launches an elevated CMD prompt window as an admin user. I'm using CreateProcessAsUser to impersonate the admin user.

I launch the CMD.EXE in administration mode and pass in the following command line programatically

-Verb RunAs -ArgumentList '/k start regsvr32.exe "C:Program Files\mydll.dll"

However, I always receive the following error?

enter image description here

Would anybody know why I can't run Regsvr32.exe from an elevated command prompt?

P_Fitz
  • 819
  • 9
  • 16
  • I'm guessing here but did you try running the app under UAC? – Mike Cheel Mar 02 '17 at 17:27
  • My problem is that I need to run this on a user PC. The user will not have admin rights so I need to temporarily run in admin mode to copy files, register dlls etc... The file copy piece works as expected but its the Regsvr32 peice that falls over. – P_Fitz Mar 02 '17 at 17:29
  • But I am asking if it works under UAC. This will tell us if that is the problem or if it is something else. – Mike Cheel Mar 02 '17 at 17:30
  • Apologies - Yes, running under UAC will work without any issues. – P_Fitz Mar 02 '17 at 17:31
  • OK so how are you getting the admin credentials? This might be as simple as embedding an application manifest in your app so that when they start it it prompts them for UAC from the gitgo. – Mike Cheel Mar 02 '17 at 17:32
  • See here though for caveat: http://stackoverflow.com/a/2823884/426422 – Mike Cheel Mar 02 '17 at 17:34
  • The admin credentials are contained within my app when I make a call to CreateProcessAsUser. I've hard coded the admin credentials for now (not ideal I know). What I do is launch CMD and then pass in the above command as an argument. It's at the point when Regsvr32.exe gets called in the elevated command prompt that my problem occurs. Apologies if I'm not explaining my working appropriately. – P_Fitz Mar 02 '17 at 17:52
  • Unfortunately UAC appears to be the problem and there aren't too many ways around it. – Mike Cheel Mar 02 '17 at 17:54

0 Answers0