我需要一个我的.exe始终以管理员身份运行而不提示UAC.我的程序将安装设置,这将具有一次管理员权限,我需要在此设置中执行这样的步骤,我的exe将始终作为管理员执行而不提示UAC.
到目前为止我找到了2个解决方案:
1.使用自定义服务,这将为我提升程序.
2.使用任务计划程序.
还有其他解决方案吗?有些表现可能吗?
谢谢.
我有一个WPF C#项目,我正在实现Windows文件夹选项的设置.其中之一是"单击以打开项目"(而不是双击).当我更改注册表项时,我需要刷新我找到解决方案的Windows资源管理器.但桌面不刷新,甚至手动刷新它不会应用更改.我使用过IActiveDesktop :: ApplyChanges方法,但没有用(或者我犯了一个错误).我也使用过这段代码片段,但它仍然没有应用我所做的更改:
SHChangeNotify(0x8000000, 0x1000, IntPtr.Zero, IntPtr.Zero);
Run Code Online (Sandbox Code Playgroud)
这里是我用来刷新Win Explorer的完整代码片段(女巫来自这个网站):
[System.Runtime.InteropServices.DllImport("Shell32.dll")]
private static extern int SHChangeNotify(int eventId, int flags, IntPtr item1, IntPtr item2);
public static void RefreshWindowsExplorer()
{
// Refresh the desktop
SHChangeNotify(0x8000000, 0x1000, IntPtr.Zero, IntPtr.Zero);
// Refresh any open explorer windows
// based on http://stackoverflow.com/questions/2488727/refresh-windows-explorer-in-win7
Guid CLSID_ShellApplication = new Guid("13709620-C279-11CE-A49E-444553540000");
Type shellApplicationType = Type.GetTypeFromCLSID(CLSID_ShellApplication, true);
object shellApplication = Activator.CreateInstance(shellApplicationType);
object windows = shellApplicationType.InvokeMember("Windows", System.Reflection.BindingFlags.InvokeMethod, null, shellApplication, new object[] { });
Type windowsType = windows.GetType();
object count = windowsType.InvokeMember("Count", System.Reflection.BindingFlags.GetProperty, …Run Code Online (Sandbox Code Playgroud)