powershell - 使用 Powershell 创建将参数传递给 shell32.dll 的快捷方式
问题描述
因此,我正在尝试制作一个“创建快捷方式”脚本以在我的用户桌面上生成一个链接,以将它们直接带到 Windows 10 中的“添加打印机向导”。从编程上讲,我很确定这是不可能的,但它是来自上面的指令。当脚本运行时,Arguments 字段被删除。
更新
我可以手动创建它,但不能以编程方式创建。
帮助我 StackOverFlow ...你是我们唯一的希望
$sArguments = "shell32.dll,SHHelpShortcuts_RunDLL PrintersFolder"
$AppLocation = "C:\Windows\System32\rundll32.exe"
$WshShell = New-Object -ComObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut("$env:PUBLIC\Desktop\UAT Devices and Printers.lnk")
$Shortcut.TargetPath = $AppLocation
$Shortcut.Arguments = $sArguments
$Shortcut.IconLocation = "devicecenter.dll,0"
$Shortcut.Description ="UAT Devices and Printers"
$Shortcut.WorkingDirectory ="C:\Windows\System32"
$Shortcut.Save()
我觉得问得很愚蠢,但是谁能看到我错过了什么?
解决方案
如果您只是想触发Add Printer Driver Wizard
,这里是您的代码的固定版本(参数不同,参考:https ://docs.microsoft.com/en-us/windows-server/administration/windows-commands/rundll32-printui ):
$sArguments = "printui.dll,PrintUIEntry /id"
$AppLocation = "C:\Windows\System32\rundll32.exe"
$WshShell = New-Object -ComObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut("$env:PUBLIC\Desktop\UAT Devices and Printers.lnk")
$Shortcut.TargetPath = $AppLocation
$Shortcut.Arguments = $sArguments
$Shortcut.IconLocation = "devicecenter.dll,0"
$Shortcut.Description ="UAT Devices and Printers"
$Shortcut.WorkingDirectory ="C:\Windows\System32"
$Shortcut.Save()
推荐阅读
- brute-force - 确定我正在使用的哈希类型以在 hashcat 中使用
- amazon-web-services - 如何在 CloudWatch 的仪表板上显示 AWS 服务的正常运行时间百分比?
- python - 通过代码失败胶水作业(即手动)
- node.js - 如何在测试期间提高 puppeteer 启动性能
- sql-server - 实体框架 6:找不到对象,因为它不存在或您没有权限
- azure - 将版本化 api 与 Azure API 管理一起使用时,版本在 url 中出现两次
- ios - UIWindowScene AVPlayerViewController 方向问题 ios 13
- google-bigquery - BigQuery:将数据导出到分层文件夹:YYYY/MM/DD
- javascript - 在 Ant Design 中强制列需要排序
- python - teradatasql:运行时/cgo:无法获得 pthread_keys