尝试在Powershell中编写带有启动参数的.exe脚本



我是PowerShell的新手,我正在尝试创建一个脚本,该脚本将使用特定于此.exe文件的参数卸载戴尔数据保护。

下面是我所拥有的减去我将使用的实际信用:

Start-Process -Filepath C:Programfiles (x86)DellDell Data ProtectionDataSecurityUninstaller.exe" -argumentlist "CMG_DECRYPT=1 FORENSIC_ADMIN="ExampleUser" FORENSIC_PWD="Passw0rd" NOREBOOT /silent"

我:

A positional parameter cannot be found that accepts argument "ExampleUser" FORENSIC_PWD="Passw0rd" NOREBOOT

当我把它放入CMD时,它工作了。我想我不知道如何正确处理运行参数。

这两个都可以:

Start-Process -Filepath 'C:Programfiles (x86)DellDell Data ProtectionDataSecurityUninstaller.exe' -ArgumentList 'CMG_DECRYPT=1 FORENSIC_ADMIN="ExampleUser" FORENSIC_PWD="Passw0rd" NOREBOOT /silent'
Start-Process -Filepath 'C:Programfiles (x86)DellDell Data ProtectionDataSecurityUninstaller.exe' -ArgumentList 'CMG_DECRYPT=1', 'FORENSIC_ADMIN="ExampleUser"', 'FORENSIC_PWD="Passw0rd"', 'NOREBOOT', '/silent'

您在这里打开","CMG,然后在这里关闭_ADMIN=",这导致cmdlet认为您将ExampleUser...作为不同参数的输入,因此出现错误。

另外,您可能只想从当前会话运行卸载程序,在这种情况下不需要Start-Process。我想应该是这样的:

& 'C:Programfiles (x86)DellDell Data ProtectionDataSecurityUninstaller.exe' CMG_DECRYPT=1 FORENSIC_ADMIN="ExampleUser" FORENSIC_PWD="Passw0rd" NOREBOOT /silent

最新更新