我已經使用這個像瘋了一樣,所以如果這已經發布之前,道歉。SCCM .cmd腳本將無法正常工作
我通常使用.cmd腳本通過SCCM推送更新,所以我可以卸載以前的版本,並安裝新版本。
代碼:
@echo off
REM Kill IE & Java Processes
cls
echo --------------------------------------------------------
echo This will kill Browsers and Java Processes
echo --------------------------------------------------------
taskkill /F /IM iexplorer.exe
taskkill /F /IM iexplore.exe
taskkill /F /IM firefox.exe
taskkill /F /IM chrome.exe
taskkill /F /IM jusched.exe
taskkill /F /IM jp2launcher.exe
taskkill /F /IM java.exe
taskkill /F /IM javaw.exe
taskkill /F /IM jqs.exe
REM Uninstalling Old JRE Versions
cls
echo --------------------------------------------------------
echo. DO NOT CLOSE THIS WINDOW
echo. All the Java versions from your computer are being removed.
echo --------------------------------------------------------
wmic product where "name like 'J2SE%%'" call uninstall
wmic product where "name like 'Java 2%%'" call uninstall
wmic product where "name like 'Java 3%%'" call uninstall
wmic product where "name like 'Java 4%%'" call uninstall
wmic product where "name like 'Java 5%%'" call uninstall
wmic product where "name like 'Java(TM) 6%%'" call uninstall
wmic product where "name like 'Java 7%%'" call uninstall
wmic product where "name like 'Java 8%%'" call uninstall
REM Installing Java 1.8u77
cls
echo --------------------------------------------------------
echo .
echo .
echo . Installing Java Runtime Environment - Please Wait.
echo . (This window will close once installed)
echo .
mkdir c:\programdata\oracle\java
mkdir "c:\windows\sun\java\deployment"
copy java.settings.cfg c:\programdata\Oracle\Java\java.settings.cfg >>c:\programdata\oracle\java\copylog.log
REM Installing JRE 32-bit
"%~dp0jre-8u77-windows-i586.exe" INSTALL_SILENT=1 STATIC=0 AUTO_UPDATE=0 WEB_JAVA=1 WEB_ANALYTICS=0 EULA=0 REBOOT=0
REM If 64-bit Windows JRE 64-bit is also required
REM Installing JRE 64-bit
if exist "%ProgramFiles(x86)%\" "%~dp0jre-8u77-windows-x64.exe" INSTALL_SILENT=1 STATIC=0 AUTO_UPDATE=0 WEB_JAVA=1 WEB_ANALYTICS=0 EULA=0 REBOOT=0
REM Disable automatic updates
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /v SunJavaUpdateSched /f
reg add "HKEY_LOCAL_MACHINE\Software\JavaSoft\Java Update\Policy" /v EnableJavaUpdate /t REG_DWORD /d 0 /f
copy deployment.config c:\windows\sun\java\deployment\deployment.config >>c:\programdata\oracle\java\copylog.log
copy deployment.properties c:\windows\sun\java\deployment\deployment.properties >>c:\programdata\oracle\java\copylog.log
copy exception.sites c:\windows\sun\java\deployment\exception.sites >>c:\programdata\oracle\java\copylog.log
REM Return exit code to SCCM
exit /B %EXIT_CODE%
出於某種原因,它永遠只能安裝64位版本,不可能兼顧。我做了一個Package和Application,結果相同。我已經刪除了「if exists」%ProgramFiles(x86)%\「」部分,沒有任何內容。我創建了獨立的部署,並首先調用了32位,沒有任何東西。
我很遺憾,爲什麼它只安裝64位版本。
任何幫助,將不勝感激。
感謝
編輯:是的,我已經測試它在本地,當通過SCCM
沒有部署腳本的偉大工程編輯:我試圖在此腳本部署到Windows 8.1和7噸的機器,從SCCM 2012 R2服務器。之前我已經部署了這種格式,而且根據經驗,有時候新的程序會讓事情變得不合時宜。