如何使用C#.NET以管理员身份运行bat文件? [英] How to run bat file run as administrator using C# .NET?

查看:979
本文介绍了如何使用C#.NET以管理员身份运行bat文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



如何使用c#.net以管理员身份运行bat文件?



我正在尝试此代码,但我的脚本没有使用c#运行。



我的脚本文件内容: -



Hello,

How to run bat file run as administrator using c# .net?

I am trying this code but my script is not running using c#.

My script bat file content:-

CD..
CD..
CD Program Files (x86)\ABC\ABC 
TAKEOWN /F ABC_Data /R /A







当我以管理员身份手动运行时,此脚本正在运行。






This script is running when i have manually run as administrator.

Please help me.





先谢谢。



Ankit Agarwal

软件工程师



我尝试过:



ProcessStartInfo info = new ProcessStartInfo(Application.StartupPath + @\ script .bat);

info.UseShellExecute = true;

info.Verb =runas;

Process.Start(info);



Thanks in Advance.

Ankit Agarwal
Software Engineer

What I have tried:

ProcessStartInfo info = new ProcessStartInfo(Application.StartupPath + @"\Script.bat");
info.UseShellExecute = true;
info.Verb = "runas";
Process.Start(info);

推荐答案

请参阅此处:托管代码中的UAC提升:启动提升的流程 [ ^ ]


这篇关于如何使用C#.NET以管理员身份运行bat文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆