.ps1 脚本双击时不运行

发布于 2025-01-19 16:06:53 字数 489 浏览 5 评论 0原文

我有一个要运行的脚本,当我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

清音悠歌 2025-01-26 16:06:53

您可以通过右键单击并选择“使用PowerShell运行”来运行.ps1文件。
如果要通过双击来运行PowerShell脚本,则可以创建一个快捷方式:

在Windows上,

  1. 右键单击文件Explorer并
  2. 在要求位置时创建一个快捷方式,键入: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,

  1. Right click in your file explorer and create a shortcut
  2. When it asks for location, type: powershell.exe -F "pathofscript". So if your script is located in C:\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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文