Execute “real life” command line from variable in Powershell

前端 未结 3 597
暗喜
暗喜 2020-12-10 21:36

When I for example read some uninstall string from the registry like \"C:\\Program Files (x86)\\Opera\\Launcher.exe\" /uninstall I can copy it to the Powershell

3条回答
  •  有刺的猬
    2020-12-10 22:25

    I think Bill Stewart's answer is the right way to do it. If for some reason you can't get Bill's answer to work you could use Invoke-Expression to do it though.

    $var = '"C:\Program Files (x86)\Opera\Launcher.exe" /uninstall'
    Invoke-Expression "& $var"
    

提交回复
热议问题