.ps1 脚本双击时不运行
我有一个要运行的脚本,当我在 PowerShell ISE 上使用该脚本时,他工作正常,但我需要在 .ps1 文件上运行(双击),当我尝试此操作时,会发生什么事情...powershell 的窗口打开,但我的脚本没有打开跑步。
我的代码是:
$path = "W:\Processos\Integracao\Titulos Carrefour"
$path2 = "\\fileserver\departamentos$\Matriz\Titulos Carrefour"
Set-Location $path
Get-ChildItem -Path "$path2\*.csv" -Recurse | Move-Item -Destination $path -Force
Start-Process 'winscp.com' -ArgumentList /script=envio.scp -Wait
i have a script to run and he works fine when i use that on PowerShell ISE, but i need to run at .ps1 file (double clicking) and when i try this, hothing happen... the powershell's window opens but my script dont run.
my code is:
$path = "W:\Processos\Integracao\Titulos Carrefour"
$path2 = "\\fileserver\departamentos$\Matriz\Titulos Carrefour"
Set-Location $path
Get-ChildItem -Path "$path2\*.csv" -Recurse | Move-Item -Destination $path -Force
Start-Process 'winscp.com' -ArgumentList /script=envio.scp -Wait
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过右键单击并选择“使用PowerShell运行”来运行.ps1文件。
如果要通过双击来运行PowerShell脚本,则可以创建一个快捷方式:
在Windows上,
powershell.exe -f“ pathofscript” pathofscript“ << /代码>。因此,如果您的脚本位于
c:\ asdf \ hello.ps1
中,您将输入:powershell.exe -f“ c:\ asdf \ asdf \ hello.ps1”
现在,您有了一个快捷方式,双击时将运行您的脚本。
注意:如果将.ps1脚本移动到其他地方,则需要更新快捷方式以反映这一点。
You can run .ps1 files by right clicking and selecting "Run with PowerShell".
If you want to run PowerShell scripts by double clicking, you can create a shortcut:
On Windows,
powershell.exe -F "pathofscript"
. So if your script is located inC:\asdf\hello.ps1
, you would type:powershell.exe -F "C:\asdf\hello.ps1"
Now you have a shortcut that will run your script when double clicked.
Note: If you move your .ps1 script somewhere else, you'll need to update the shortcut to reflect that.