Windows 7 컴퓨터에서 Java를 제거하는 스크립트를 작성했습니다.
[...]
$p2=start-process "msiexec.exe" -arg "/X $uninstall32 /qn REMOVE=ALL /norestart " -PassThru -wait -verb runAs
$p2.WaitForExit()
[...]
어딘가 $uninstall32 = {26A24AE4-039D-4CA4-87B4-2F03217065FF}
이 ps1 파일을 관리자로 직접 호출하면 모든 것이 잘되었습니다. 업데이트 프로세스의 순서로 파일에서 내 (작동하는) ps1 파일을 호출해야 .bat
합니다. 이런 ps1
식으로 내 파일을 호출 합니다.
if exist "%programfiles%\java\jre7" (
powershell.exe -NoProfile -Command "Set-ExecutionPolicy Bypass"
powershell.exe -NoProfile -file %~dp0uninstalljava7.ps1
powershell.exe -NoProfile -Command "Set-ExecutionPolicy "restricted"
)
그렇다면 erythin은 잘못된 것입니다 : msiexec가 1619를 던졌습니다.
나는 그것을 이해하지 않는다?!
해결됨 :
나를 위해 작업 솔루션은 다음과 같습니다.
Set-StrictMode -Version 2
$uninstall32key = "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall"
$uninstall64key = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
$hklm32 = [Microsoft.Win32.RegistryKey]::OpenBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine, [Microsoft.Win32.RegistryView]::Registry32)
$hklm64 = [Microsoft.Win32.RegistryKey]::OpenBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine, [Microsoft.Win32.RegistryView]::Registry64)
$key32 = $hklm32.OpenSubKey($uninstall32key)
$key64 = $hklm64.OpenSubKey($uninstall64key)
$subkeys32 = $key32.GetSubKeyNames()
$subkeys64 = $key64.GetSubKeyNames()
foreach($subkey in $subkeys32)
{
$key = $hklm32.OpenSubKey($uninstall32key+"\\"+$subkey)
$displayName = $key.GetValue("DisplayName")
if ($displayName -match "Java 7")
{
$uninstall32 =$key.GetValue("UninstallString")
if ($uninstall32) {
$uninstall32 = $uninstall32 -Replace "msiexec.exe","" -Replace "/I","" -Replace "/X",""
$params = @{
"FilePath" = "$Env:SystemRoot\system32\msiexec.exe"
"ArgumentList" = @(
"/x"
$uninstall32
"/qn"
"REMOVE=ALL"
"/norestart"
)
"Verb" = "runas"
"PassThru" = $true
}
$app1 = start-process @params
$app1.WaitForExit()
}
}
}
foreach($subkey in $subkeys64)
{
$key = $hklm64.OpenSubKey($uninstall64key+"\\"+$subkey)
$displayName = $key.GetValue("DisplayName")
if ($displayName -match "Java 7")
{
$uninstall64 =$key.GetValue("UninstallString")
if ($uninstall64) {
$uninstall64 = $uninstall64 -Replace "msiexec.exe","" -Replace "/I","" -Replace "/X",""
$params = @{
"FilePath" = "$Env:SystemRoot\system32\msiexec.exe"
"ArgumentList" = @(
"/x"
$uninstall64
"/qn"
"REMOVE=ALL"
"/norestart"
)
"Verb" = "runas"
"PassThru" = $true
}
$app1 = start-process @params
$app1.WaitForExit()
}
}
}
이 방법으로 시도하십시오.
$appGUID = "{26A24AE4-039D-4CA4-87B4-2F03217065FF}"
$params = @{
"FilePath" = "$Env:SystemRoot\system32\msiexec.exe"
"ArgumentList" = @(
"/x"
$appGUID
"/qn"
"REMOVE=ALL"
"/norestart"
)
"Verb" = "runas"
"PassThru" = $true
}
$app = start-process @params
$app.WaitForExit()
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다