PowerShell执行策略
我正在从映射驱动器运行一个 EXE 文件,并在运行时提供一些参数(它是更新/修补程序)。但是,当从映射的网络驱动器运行 EXE 文件时,不支持 /q
或静默操作开关。如果将相同的 EXE 文件复制到本地,则可以正常工作。
我正在运行
Start-Process -Filepath "z:\abc.exe" -ArgumentList '/quiet /norestart' -Wait
这会弹出一个对话框来确认我的操作,但我想抑制它。
如果我在本地复制 abc.exe 并运行,
Start-Process -Filepath "c:\abc.exe" -ArgumentList '/quiet /norestart' -Wait
它就可以正常工作。
我检查了执行策略,并将其设置为无限制。我该如何解决这个问题?
I am running an EXE file from a mapped drive and supplying a few arguments while running it (it is an update/hotfix). However, the /q
or silent operation switch is not honored when the EXE file is run from the mapped network drive. If the same EXE file is copied over locally, it works fine.
I am running
Start-Process -Filepath "z:\abc.exe" -ArgumentList '/quiet /norestart' -Wait
This pops up a dialog box to confirm my action, but I want to suppress it.
If I copy abc.exe locally and run,
Start-Process -Filepath "c:\abc.exe" -ArgumentList '/quiet /norestart' -Wait
it just works fine.
I checked Execution policy and it is set to Unrestricted. How can I fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
该对话框可能是一个安全警告,表明您正在通过网络安装某些内容,与 EXE 文件的静默安装无关。
The dialog may be a security warning that you are installing something over the network and not related to the quiet install of the EXE file.
我在添加网络路径(字母或 UNC 时遇到了问题- 我不记得了)到
$env:PSModulePath
。每次我想从网络加载模块时,都会出现一条警告消息。如果你想要的话,可能是同样的事情。从用户配置文件中的网络驱动器获取 PS1 文件。它来自 Internet Explorer 策略:某些计算机配置为将 UNC 路径视为与 Internet 相同的安全区域(而不是 Intranet)。这是 Internet Explorer 的“增强安全配置” 。在这种情况下,当 PowerShell 从 UNC 运行脚本时,其响应与 Windows 资源管理器 shell 相同小路:
解决此问题的一种方法是将源服务器添加到 Internet Explorer 的受信任站点,或 更改“UncAsIntranet”配置属性。
您还可以查看一下:下载的 EXE 文件已被锁定。
NTFS 在文件扩展属性中跟踪这一点。查看 EXE 文件的属性(抱歉,是法语。这里的“Débloquer”按钮是“解锁”按钮):
I encountered the problem when I added a network path (letter or UNC - I don't remember) to
$env:PSModulePath
. Each time I wanted to load a module from the network, a warning message appeared. It may be the same thing if you want to. source
a PS1 file from a network drive in the user's profile.It was coming from an Internet Explorer policy: Some machines are configured to treat UNC paths as the same security zone as the Internet (as opposed to the intranet.) This is Internet Explorer’s "Enhanced Security Configuration". In this case, PowerShell responds the same as the Windows Explorer shell when it runs scripts from a UNC path:
One way to fix this is by adding the source server to Internet Explorer’s Trusted Sites, or changing the “UncAsIntranet” configuration property.
You can also have a look to this: The EXE files coming from a download are locked.
And NTFS keeps track of that in the file extended attribute. Look in the properties of the EXE file (sorry, in French. Here the 'Débloquer' button is the 'Unlock' button):