I have this simple PowerShell script:
Copy-Item -path ('\\PC1\Images\' + (Get-ChildItem -Path '\\PC1\Images' -Attributes !Directory *.dat | Sort-Object -Descending -Property LastWriteTime | Select-Object -first 1)) 'C:\Temp\PC1\screen.jpg' | Start-Process 'C:\Program Files\Google\Chrome\Application\chrome.exe' -ArgumentList 'file:///C:/Temp/PC1/screen.jpg'
If I run this command from a PowerShell window, it works fine. If I save it as .ps1 file and run it from Windows Explorer, nothing happens (Chrome does not open the desired URL).
What can be done to allow to execute this script from some shortcut? (I want to add a shortcut/icon to my Windows taskbar for fast access).