禁用UAC,重新启动并安装程序

时间:2018-12-05 13:37:45

标签: powershell-workflow

我试图禁用UAC,重新启动计算机并安装程序。我发现an article如何创建工作流程,但不适用于我。当我运行它一次时,计算机将重新启动,UAC仍处于启用状态,什么也没发生。

workflow Resume_Workflow
{
    Set-ItemProperty -Path REGISTRY::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System -Name ConsentPromptBehaviorAdmin -Value 0 
    Restart-Computer -Wait
    Start-Process msiexec.exe -Verb runAs -PassThru -Wait -ArgumentList '/I C:\tmp\_deployment\tightvnc-2.8.11-gpl-setup-64bit.msi /quiet /norestart'
}
# Create the scheduled job properties
$options = New-ScheduledJobOption -RunElevated 
$AtStartup = New-JobTrigger -AtStartup

    # Register the scheduled job
    Register-ScheduledJob -Name Resume_Workflow_Job -Trigger $AtStartup -ScriptBlock ({[System.Management.Automation.Remoting.PSSessionConfigurationData]::IsServerManager = $true; Import-Module PSWorkflow; Resume-Job -Name new_resume_workflow_job -Wait}) -ScheduledJobOption $options
    # Execute the workflow as a new job
    Resume_Workflow -AsJob -JobName new_resume_workflow_job

有什么想法吗?

感谢您的帮助。

0 个答案:

没有答案