powershell - 尝试在 Powershell 中使用启动参数编写 .exe 脚本
问题描述
我是 PowerShell 的新手,我正在尝试创建一个脚本,该脚本将使用特定于此 .exe 文件的参数卸载 Dell Data Protection。
这是我减去我将使用的实际信用的内容:
Start-Process -Filepath C:\Programfiles (x86)\Dell\Dell Data Protection\DataSecurityUninstaller.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)\Dell\Dell Data Protection\DataSecurityUninstaller.exe' -ArgumentList 'CMG_DECRYPT=1 FORENSIC_ADMIN="ExampleUser" FORENSIC_PWD="Passw0rd" NOREBOOT /silent'
Start-Process -Filepath 'C:\Programfiles (x86)\Dell\Dell Data Protection\DataSecurityUninstaller.exe' -ArgumentList 'CMG_DECRYPT=1', 'FORENSIC_ADMIN="ExampleUser"', 'FORENSIC_PWD="Passw0rd"', 'NOREBOOT', '/silent'
您在"
此处打开"CMG
然后在此处关闭,_ADMIN="
这会导致 cmdlet 认为您将ExampleUser...
其作为不同参数的输入,因此会出现错误。
此外,您可能只想从当前会话运行卸载程序,Start-Process
在这种情况下不需要。我相信它会是这样的:
& 'C:\Programfiles (x86)\Dell\Dell Data Protection\DataSecurityUninstaller.exe' CMG_DECRYPT=1 FORENSIC_ADMIN="ExampleUser" FORENSIC_PWD="Passw0rd" NOREBOOT /silent
推荐阅读
- laravel - 使用 $validator->errors->add() 来自自定义验证器函数内部的 Laravel 自定义错误消息
- vue.js - .NET CORE web api 未检测到更改
- jquery - jquery识别页面具有多个表单的表单
- angular - 如何从 api 获取 JSON 数组对象值?
- python - SAS 与 Python
- css - CSS:在模态中打印长 div,在 IE 中没有第二页
- sed - 如何使用 echo tail 创建大文件的子集
- python - 从 Lotus Notes 视图获取数据的有效方法
- r - 如何在 R 中为函数使用条件语句和返回值?
- c# - WPF / C#:通过按钮从 DataGrid 中的 List<> 中删除项目