Skip to content

Instantly share code, notes, and snippets.

@turboBasic
Last active December 25, 2017 04:24
Show Gist options
  • Save turboBasic/f37b7dfe413485bea1ad2252236231cd to your computer and use it in GitHub Desktop.
Save turboBasic/f37b7dfe413485bea1ad2252236231cd to your computer and use it in GitHub Desktop.
[Pass-ArgumentsToPowershell.cmd] Calling #Powershell from Cmd.exe with complex arguments with quotes and spaces
@echo off
setlocal enabledelayedexpansion
set args=%*
set args=%args:"='%
set args=%args:(=`(%
set args=%args:)=`)%
set invalid="='
if !args! == !invalid! ( set args= )
powershell.exe -noLogo -noProfile -executionPolicy Unrestricted -command "Invoke-Shimgen -path %args%; exit $lastExitCode"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment