我有一个脚本可以将 Adobe Reader 设置为设置 .pdf 扩展名的默认程序。我希望脚本创建一个文件和注册表,但在登录或重新启动它后,它会删除此文件和注册表。不幸的是,当我登录时,一切都被删除了,但 Adobe 尚未设置为默认程序。有没有人知道如何延迟删除脚本的执行,或者如何在登录后退出并完成脚本?
workflow Do-Reboot-Do {
New-Item C:\Users\$env:UserName\Downloads\AdobeDefaultPDF.xml -ItemType File
Set-Content C:\Users\$env:UserName\Downloads\AdobeDefaultPDF.xml '<?xml version="1.0" encoding="UTF-8"?>
<DefaultAssociations>
<Association Identifier=".pdf" ProgId="AcroExch.Document.DC" ApplicationName="Adobe Acrobat Reader DC" />
</DefaultAssociations>'
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\System" /v DefaultAssociationsConfiguration /t REG_SZ /d "C:\Users\$env:UserName\Downloads\AdobeDefaultPDF.xml"
Restart-Computer -Wait
Remove-Item C:\Users\$env:UserName\Downloads\AdobeDefaultPDF.xml
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\System" -Name "DefaultAssociationsConfiguration"
}
Do-Reboot-Do
干杯!