批处理脚本,PowerShell的,而不是触发UAC在Windows [英] Batch scripting, Powershell, and not triggering the UAC in Windows

查看:676
本文介绍了批处理脚本,PowerShell的,而不是触发UAC在Windows的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要寻找客场高架模式(运行方式管理员)运行的批处理文件,以便它不跳闸的UAC提示用户交互。我们有一些注册表编辑,除其他事项外,我们在其中触发UAC提示输入每个运行注册表我们的登录脚本做的。

I am looking for away to run batch files in elevated mode (runas administrator) so that it doesn't trip the UAC to prompt for user interaction. We have some registry edits, among other things, that we do in our login scripts which trigger the UAC to prompt for each registry that is run.

我认识到,这种失败的UAC的目的,但如果是在启用了UAC的机器上运行的批处理文件的一些方法就好。

I realize that this sort of defeats the purpose of the UAC, but it would be nice if there was some way of running batch files on machines that have UAC enabled.

这些批处理文件需要能够无需任何用户交互运行(主要为登录脚本,以及一些管理脚本)。我们不使用Active Directory域,所以希望有没有为AD域的解决方案。

These batch files need to be able to run without any user interaction (they are mainly login scripts, and some administrative scripts). We are not using an Active Directory domain, so hopefully there is a solution for none AD domains.

这是我已经找到了解决方案,至今如下:

The solutions that I have found so far are as follows:


  1. 完全禁用UAC - 我们通常这样做,但我们可能会运行到某些情况下,我们不能将其禁用。

  1. Disable the UAC altogether - We normally do this, but we might be running into some situations where we cannot disable it.

创建一个快捷方式,我们希望在提升模式下运行该批处理文件。进入快捷方式的属性>快捷方式选项卡> Advaned>勾选以管理员身份运行

Create a shortcut to the batch file we wish to run in elevated mode. Go to the properties of the shortcut > Shortcut tab > Advaned > Check off "Run as Administrator"


  • 这个解决方案似乎工作,但该快捷方式的初期磨合导致UAC提示上来。批处理文件中运行的所有命令不会导致UAC提示。接近解决方案,但它会很高兴没有得到任何提示。

3。
运行与运行方式命令的批处理文件。

3. Running the batch file with the 'runas' command.


  • 我试过,但它仍然没有看到从促使实现提升到prevent的UAC。

  • 此外,使用echo密码|运行方式.....方法来提供密码似乎并没有工作的权利,所以我总是有在密码输入。

这是我在想其他的事情,但我还没有真正研究尚未就是做PowerShell脚本运行/工作在一个环境下,启用UAC更好?是否视窗信任认证的PowerShell脚本,让他们不会触发UAC运行无阻?

The other thing that I was thinking, but I haven't really researched yet is, do powershell scripts run/work better in an environment where the UAC is enabled? Does Windows 'trust' certified powershell scripts and allow them to run unimpeded without triggering the UAC?

从我已阅读,这是周围的其他UAC没有办法再禁用它。但我只是想看看是否有人也许能揭示出这个主题的一些额外的光。

From what I have read, these is no way around the UAC other then disabling it. But I just wanted to see if anyone might be able to shed some additional light on this topic.

感谢您,

干杯

推荐答案

注册表操作为当前用户具​​有访问不会触发本身UAC提示。

Registry manipulation for which the current user has access will not itself trigger a UAC prompt.

不过使用与需要提升,如果运行的是未提升的管理员会提示一个应用程序清单。

However using an application with a manifest that requires elevation if running as un-elevated administrator will prompt.

您尝试使用 REGEDIT.EXE 来执行批处理操作?如果是这样用 REG.EXE 更换(使用的cmd.exe ),或者更好,PowerShell中的内置注册表支持。

Are you trying to use regedit.exe to perform batch operation? If so replace with reg.exe (using cmd.exe) or, better, PowerShell's inbuilt registry support.

例如:

get-itemproperties 'HKLM:\SOFTWARE\Classes\Folder'

不会需要提升(因为这关键是每个人可读),但该键设置属性将需要提升的PSH会话。

will not require elevation (as that key is readable by everyone), but setting a property on that key will require an elevated PSH session.

这是另一种方法,如果您正在执行需要管理访问权限的操作(需要修改权限与ACL一些对象限制修改管理员)。或者,一些非管理员不可能做到UAC与否,无需输入管理员帐户的凭据。

An alternative approach, if you are performing operations that require administrative access (need modify access to some object with ACL that limits modification to administrators). Or, something a non-administrator could never do UAC or not, without enter an administrator's account's credentials.

考虑使用任务计划程序:在用户登录触发器,但在一个特定提升的管理员帐户设置

Consider using Task Scheduler: a trigger of on user logon but configured under a specific elevated administrator account.

摘要:真正需要知道的你正在做的事情至少有一个触发UAC详细

Summary: really need to know at least one of the things you are doing that triggers UAC in detail.

这篇关于批处理脚本,PowerShell的,而不是触发UAC在Windows的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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