// @param szVersion Version to check, e.g. "v2.0", "v3.5" and so on.
function DetectDotNet(szVersion)
NUMBER nRootKey, nResult;
LIST lstVersions;
BOOL bRet;
STRING szString;
begin
bRet
= FALSE;
nRootKey = HKEY_LOCAL_MACHINE;
lstVersions =
ListCreate(STRINGLIST);
if (lstVersions = LIST_NULL) then
MessageBox ("Unable to create necessary lists.", SEVERE);
abort;
endif;
if (RegDBSetDefaultRoot(nRootKey) = 0)
then
nResult = RegDBQueryKey("SOFTWARE\\Microsoft\\NET Framework
Setup\\NDP",
REGDB_KEYS, lstVersions);
if (nResult =
0) then
// Get the first string in the list.
nResult = ListGetFirstString(lstVersions, szString);
//
Loop while list items continue to be retrieved.
while (nResult !=
END_OF_LIST)
// Detect the current
element.
if (StrFind(szString, szVersion) = 0)
then
bRet = TRUE;
nResult =
END_OF_LIST; // Force to exit
else
//
Get the next string in the list.
nResult =
ListGetNextString(lstVersions, szString);
endif;
endwhile;
endif;
endif;
ListDestroy(lstVersions);
return bRet;
end;
无人值守安装.Net Framework 3.5的批处理脚本(传入参数是dotnetfx35.exe所在的绝对目录,解决自动连网下载的问题):
@echo off
setlocal
set INSTALLER31="%~1WindowsInstaller-KB893803-v2-x86.exe"
set
DOTNETFX35="%~1dotnetfx35.exe"
set
NDP35SP1="%~1NDP35SP1-KB958484-x86.exe"
echo Installing %INSTALLER31%
%INSTALLER31% /quiet /norestart
/nobackup
echo Extracting %DOTNETFX35%
%DOTNETFX35% /x:%TEMP% /passive
cd /d "%TEMP%\wcu\dotNetFramework"
echo Installing dotNetFx35setup.exe
dotNetFx35setup.exe /lang:ENU
/norestart /passive
echo Removing extracted files
cd /d "%TEMP%"
rd /s /q wcu
echo Installing %NDP35SP1%
%NDP35SP1% /norestart /passive
endlocal