How can I auto-elevate my batch file, so that it requests from UAC administrator rights if required?

后端 未结 15 1136
陌清茗
陌清茗 2020-11-22 03:59

I want my batch file to only run elevated. If not elevated, provide an option for the user to relaunch batch as elevated.

I\'m writing a batch file to set a system v

15条回答
  •  無奈伤痛
    2020-11-22 04:13

    For some programs setting the super secret __COMPAT_LAYER environment variable to RunAsInvoker will work.Check this :

    set "__COMPAT_LAYER=RunAsInvoker"
    start regedit.exe
    

    Though like this there will be no UAC prompting the user will continue without admin permissions.

提交回复
热议问题