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
*.ps1
file are opened for editing when you double-click them in File Explorer. Changing that interactively to usingpowershell.exe
to open such files (a) doesn't keep the window that the script runs in open afterwards and (b) fails with script paths that contain spaces and single quotes. To robustly make*.ps1
files execute in a stay-open window, a programmatic solution is necessary, as shown in this answer. Alternatively, for individual scripts, you can create shortcut files that launch them, as shown in ryanconmeo's answer – Blades.ps1
script, but, yes,.cmd
/.bat
files are executed when double-clicked from File Explorer, unlike.ps1
files. – Bladespowershell.exe -NoExit -File "C:\my_path\yada_yada\run_import_script.ps1" %*
instead. – Blades