无法通过PowerShell卸载Microsoft Visio Professional 2016

时间:2017-11-29 09:35:50

标签: powershell

我正在尝试卸载使用click-to-run方法安装的Visio Professional 2016安装。它适用于所有其他方法,脚本的其余部分在调用时将参数传递给函数。

这是我的PowerShell:

function try-uninstall{
    try
    {
If ($Version -match "32"){
$configFileLocation = "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE16\Office Setup Controller"
$location = "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE16\Office Setup Controller"
$ConfigFile = $scriptRoot + "\VisPro2016config.xml"
$executable = "setup.exe"
$ConfigFileName = "VisPro2016config.xml"
}

If ($Version -match "64"){
$configFileLocation = "C:\Program Files\Common Files\microsoft shared\OFFICE16\Office Setup Controller"
$location = "C:\Program Files\Common Files\microsoft shared\OFFICE16\Office Setup Controller"
$ConfigFile = $scriptRoot + "\VisPro2016config.xml"
$executable = "setup.exe"
$ConfigFileName = "VisPro2016config.xml"
}

If ($Version -match "MS32"){
$configFileLocation = "C:\Program Files\Common Files\microsoft shared\ClickToRun"
$configFileLocation = "C:\Program Files\Common Files\microsoft shared\ClickToRun"
$location = "C:\Program Files\Common Files\microsoft shared\ClickToRun"
$ConfigFile = $scriptRoot + "\VisPro2016MSconfig.xml"
$executable = "OfficeClickToRun.exe"
$ConfigFileName = "VisPro2016MSconfig.xml"
}

If ($Version -match "MS64"){
$configFileLocation = "C:\Program Files\Common Files\microsoft shared\ClickToRun"
$location = "C:\Program Files\Common Files\microsoft shared\ClickToRun"
$ConfigFile = $scriptRoot + "\VisPro2016MSconfig.xml"
$executable = "OfficeClickToRun.exe"
$ConfigFileName = "VisPro2016MSconfig.xml"
}

 $VisioPro2016Uninstall = @(
                "/uninstall"
                "/config"
                "$ConfigFileName"
                )
                LogWrite "Uninstalling Microsoft Visio Professional 2016."
                $UninstallXML = (Start-Process "$executable" -ArgumentList $VisioPro2016Uninstall -Wait -Passthru).ExitCode
                LogWrite "XML error code: $UninstallXML"
                If ( $UninstallXML -ne 0){
                LogWrite "Uninstall using XML config failed"
}
}

这是我的XML:

<Configuration>
    <Remove>
        <Product ID="VisioProRetail">
            <Language ID="en-us"/>
        </Product>
    </Remove>
    <Logging Level="Standard" Path="c:\Windows\MYCOMPANY\Uninstall_Visio_Pro2016_XML"/>
    <Display Level="None" AcceptEULA="TRUE"/>
</Configuration> 

日志显示:

2017/11/28 16:32:13: No application(s) have initially beem detected for uninstall, scanning for executable
2017/11/28 16:32:13: Unable to work out the version of Visio Professional 2016 installed, now checking for MSDN version
2017/11/28 16:32:13: 32-bit version of application found
2017/11/28 16:32:16: Uninstalling Microsoft Visio Professional 2016.
2017/11/28 16:32:18: XML error code: 17100
2017/11/28 16:32:18: Uninstall using XML config failed

0 个答案:

没有答案