[英]PowerShell ExecutionPolicy and WindowStyle not usefull?
I have a simple PowerShell script (1 line) in a lnk/shortcut : 我在lnk / shortcut中有一个简单的PowerShell脚本(1行):
%windir%\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -WindowStyle hidden;cp file.jpg %temp%\file.jpg
Here are my questions : 这是我的问题:
I don't understand the utility of the parameters -ExecutionPolicy
and -WindowStyle
because no matter I write them or not it doesn't change anything. 我不了解参数-ExecutionPolicy
和-WindowStyle
的实用程序,因为无论我是否编写它们都不会改变任何内容。 The script works without showing any prompt. 该脚本在不显示任何提示的情况下起作用。 When I run a .ps1 file I must use -ExecutionPolicy Unrestricted
but here in my case I don't need -ExecutionPolicy
? 当我运行.ps1文件时,必须使用-ExecutionPolicy Unrestricted
但是在我的情况下,我不需要-ExecutionPolicy
吗?
Is there a way to replace -ExecutionPolicy Bypass
by /Bypass
only? 有没有一种方法可以仅通过/Bypass
替换-ExecutionPolicy Bypass
?
That's a legit question: 这是一个合法的问题:
powershell.exe –ExecutionPolicy Bypass
and it will start a PowerShell session that allows for running scripts and keeps the lowered permissions isolated to the currently running process. powershell.exe –ExecutionPolicy Bypass
,它将启动PowerShell会话,该会话允许运行脚本并保持降低的权限与当前正在运行的进程隔离。 See MSDN . 参见MSDN 。
powershell.exe -windowstyle hidden
hides the PowerShell application window after it has been created by the OS when the process starts. 当进程启动时, powershell.exe -windowstyle hidden
将被OS创建后隐藏PowerShell应用程序窗口。 This means the powershell.exe code that processes -WindowStyle Hidden is therefore executed after the console window is opened, and the Powershell window is shown briefly . 这意味着打开控制台窗口后,将执行处理-WindowStyle Hidden的powershell.exe代码,并简要显示Powershell窗口 。
In general, powershell.exe -NoProfile -ExecutionPolicy ByPass -File my.ps1
is how production scripts should be launched safely. 通常, powershell.exe -NoProfile -ExecutionPolicy ByPass -File my.ps1
是安全启动生产脚本的方式。
Enter powershell.exe /?
输入powershell.exe /?
and the PS prompt to show the built-in help of the available PowerShell command-line arguments. 和PS提示以显示可用的PowerShell命令行参数的内置帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.