case_study

On Vista,i want to run a .cmd file through code with admin rights. i have one cmd file created through my c#.net code. and now through same program i am trying to create new process and run that cmd file. this cmd file performs some network configuration operations which requires admin rights. but i think the new process which is created is not having admin privileges so on command prompt it shows that u require admin right to do this task. but if i run the same cmd file manually by right clicking and doing "run as administrator". then it runs successfully and performs the required task. but same file ran through process fails.

it would be great if i get some code snippet in c# for the same.

the same code is working fine on xp.

thanks.



Re: Application Compatibility for Windows Vista problem in running .cmd file in vista

Bruce N. Baker - MSFT

There's a couple of way to approach this. It's a common issue.

You need to either run your application manifested as requiresadministrator or you need to create a broker that runs an administrative process to run your cmd file.

The best way is to run as requires administrator and have a manifested program.






Re: Application Compatibility for Windows Vista problem in running .cmd file in vista

case_study

hi,

can you please tell me the way to manifest my application in c#.net

i have done that in vc++ appllication by using visual studio 2005 IDE's project properties option.

but its not the same for c#. please let me know about the same.

and also please throw some light on the broker approach also or if there is any document on it then it would be great.

thanks.





Re: Application Compatibility for Windows Vista problem in running .cmd file in vista

Bruce N. Baker - MSFT

You use either MT.exe or Mage. MT comes with the Vista SDK. It's not hard at all and I would recommend just searching google on "MT Vista Manifest" and you should find many solutions to this.






Re: Application Compatibility for Windows Vista problem in running .cmd file in vista

AndyCadley

There is a Channel 9 screencast which shows how to embed a manifest in a C# program using Visual Studio 2005. If the main purpose of your app isn't to perform administrative tasks, however, I'd recommend manifesting it with a requiredExecutionLevel of asInvoker and instead using COM elevation to temporarily elevate when required.