-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrunps.bat
47 lines (41 loc) · 1.29 KB
/
runps.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
@ECHO OFF
REM runps.bat
REM Purpose: Run a PowerShell script from a .cmd or .bat file with the
REM full path to the script WITHOUT the extension.
REM Requires: PowerShell
REM Usage: runps [scriptpath] ([args])
REM Examples: runps tfsfreeze
REM This will run "tfsfreeze.ps1" in the current directory
REM runps tfsfreeze asdf
REM This will run "tfsfreeze.ps1 asdf" in the current directory
REM runps "C:\Path With Spaces\Invoke-Webhook"
REM This will run "C:\Path With Spaces\Invoke-Webhook.ps1"
REM Notes: Use double quotes around the path if it contains spaces!
REM ECHO ARG 0 - %0
REM ECHO ARG 1 - %1
IF '%1'=='' GOTO HELP
SET SCRIPT=%1
SET EXTENSION=%~x0
IF '%EXTENSION%'=='' GOTO SETEXTENSION
GOTO RUN
:HELP
ECHO runps [scriptpath] ([args])
ECHO runps tfsfreeze
ECHO This will run "tfsfreeze.ps1" in the current directory
ECHO runps tfsfreeze asdf
ECHO This will run "tfsfreeze.ps1 asdf" in the current directory
ECHO runps "C:\Path With Spaces\Invoke-Webhook"
ECHO This will run "C:\Path With Spaces\Invoke-Webhook.ps1"
ECHO(
GOTO EOF
:SETEXTENSION
ECHO SETEXTENSION
SET SCRIPT=%FILENAME%.ps1
GOTO :RUN
:RUN
SET ARGS=%*
CALL SET PSARGS=%%ARGS:*%1=%%
REM ECHO %SCRIPT%
START powershell.exe -Command "& '%SCRIPT%' %PSARGS%"
GOTO EOF
:EOF