'Using a .cmd file to launch PowerShell scripts in a Temp folder
I'm trying to use a .cmd file to open a PowerShell script (p.ps1) in a Windows users temporary folder (specifically C:\Users\Username\AppData\Local\Temp).
However, using @echo off PowerShell.exe -ExecutionPolicy Bypass -File "$env:temp/p.ps1" errors out as "$env:temp/p.ps1" doesn't work with the File parameter.
While hard-coding the path to the PowerShell script works in launching the scripts, the cmd file will not work with separate users or lettered drives aside from mine. Looking for any suggestions on how to get over this hurdle.
Solution 1:[1]
@echo off PowerShell.exe -ExecutionPolicy Bypass -File "%TEMP%/p.ps1"
Here's some a of other Windows Environment Variables for CMD.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | another victim of the mouse |
