How Do You Execute An Arbitrary Native Command From A String PDF
How Do You Execute An Arbitrary Native Command From A String PDF
PUBLIC
Stack Overflow
Tags
How do you execute an arbitrary native Ask Question
Users
command from a string?
Jobs
scripting powershell
3 Answers
iex $command
By using our site, you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service.
Some strings won't run as-is, such as your
example #1 because the exe is in quotes.
This will work as-is, because the contents
of the string are exactly how you would run
it straight from a Powershell command
prompt:
function myeval($command) {
if ($command[0] -eq '"') { iex "& $command"
else { iex $command }
}
http://connect.microsoft.com/PowerShell/fe
edback/details/376207/
For example:
$path = 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall'
$app = 'MyApp'
$apps= @{}
Get-ChildItem $path |
Where-Object -FilterScript {$_.getvalue
ForEach-Object -process {$apps.Set_Item
$_.getvalue('UninstallString'),
By using our site, you acknowledge that you $_.getvalue('DisplayName'))
have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service.
}
foreach ($uninstall_string in $apps.GetEnumerator
$uninstall_app, $uninstall_arg = $uninstall_string
& $uninstall_app $uninstall_arg
}
By using our site, you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service.