Windows UAC

编程入门 行业动态 更新时间:2024-10-25 17:16:38
本文介绍了Windows UAC - 如何处理用户取消的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我需要生成一个具有提升权限的进程,这会导致为用户弹出 UAC 提示:

I need to spawn a process with elevated privileges which would cause a UAC prompt to pop up for the user:

using (process = new Process())
{
    process.StartInfo.FileName = fileName;
    process.StartInfo.Arguments = string.Join(" ", arg1, arg2, arg3);
    process.StartInfo.Verb = "runas";
    process.Start();
}

我遇到的问题是,如果用户在 UAC 提示中选择否",进程对象将抛出一个异常,指出操作已被用户取消".如果用户选择否,则父进程应该照常继续(生成的进程是完全可选的).除了捕获异常而什么都不做之外,还有没有更好的方法来处理这种情况?

The problem that I'm having is that if the user selects 'no' in the UAC prompt, the process object will throw an exception stating that 'The operation was canceled by the user.' If the user selects no, then the parent process should just continue as normal (the spawned process is completely optional). Is there a better way of handling this scenario other than just catching the exception and doing nothing?

推荐答案

除了捕获异常而什么都不做之外,您还想做什么?这是我唯一能想到的.

What else would you want to do instead of catching the exception and doing nothing? That is the only thing that I can think about.

这篇关于Windows UAC - 如何处理用户取消的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-29 08:32:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1186712.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Windows   UAC

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!