Link to home
Create AccountLog in
Avatar of Blowfelt82
Blowfelt82

asked on

Invoke-Expression Powershell

I am using Powershell v2.0 and am trying to run a DOS command via a PS console as follows. I have tried every type of escape sequence I know of but I cannot get this command to run? I have tried running the command directly without the invoke-expression command but this does not work either? Does anyone know how I can run a command like the one below in Powershell?

Invoke-Expression "C:\Program Files\Microsoft Visual Studio 9.0\VC\Bin\Lib -machine:IX86 -def:C:\OT\CAPABILITY\CAP.DEF -out:C:\OT\CAPABILITY\CAP.LIB"
ASKER CERTIFIED SOLUTION
Avatar of the_endjinn
the_endjinn
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of Raheman M. Abdul
Try:
$prog = "    'C:\Program Files\Microsoft Visual Studio 9.0\VC\Bin\Lib.exe'  "
$cmd = "$prog /MACHINE:IX86 /def:C:\OT\CAPABILITY\CAP.DEF /out:C:\OT\CAPABILITY\CAP.LIB"

Invoke-expression  $cmd