Changes

Heise Offline-Update

1,974 bytes removed, 07:41, 18 February 2014
Output of wsusoffline has changed - now using return code to evaluate whether a reboot is needed
Download the [http://download.wsusoffline.net] scripts. Run the downloader and select the products you want updates for. One note: if you're using the [http://wpkg.org/MS_Office_2007_Compatibility_Pack Compatibility Pack for the 2007 Office System] then download the updates for Office 2007. Those patch the Compatibility Pack as well as Office 2007.
Once all of the downloads are complete copy the contents of the "client" folder to your server. These scripts assume the %WPKGROOT% and %SOFTWAREPACKAGES% environment variables have been set in the client service or some other launch script.
Note: I increment the revision each Patch Tuesday. If you want this to run every time wpkg is run add 'execute="always"' to the package tag and disable the reboot.
offlineupdate.xml:
<?xml version="1.0" encoding="UTF-8"?>
<packages>
<package id="offlineupdatewsusoffline" name="offlineupdateWindows Offline Updates" revision="2008051313" rebootpriority="true90"> priority <check type="file" condition="exists" path="0%SYSTEMDRIVE%\netinst\wpkg\ctupdate.done"/>
<check typeinstall cmd="file" condition="exists" path="'%SystemDriveCOMSPEC% /C %PACKAGES%\netinstwsusoffline\wpkg\ctupdateofflineupdate.done" cmd'> <exit code='0' /><exit code='3010' reboot='true' /> </install>
<install cmd='cmd /c %WPKGROOT%\scripts\offlineupdate.cmd' /> <install cmd='cscript "%SOFTWARE%\ctcheck.js"' /> <upgrade include="install" /> <remove cmd='cmd %COMSPEC% /c C del /f "%SystemDriveSYSTEMDRIVE%\netinst\wpkg\ctupdate.done"' />
</package>
<source lang="dos">
@echo off
:: Make sure that the log directly exists and is hidden
mkdir -p %SystemDrive%\netinst\wpkg
attrib +H %SystemDrive%\netinst
del %SystemDrive%\netinst\wpkg\ctupdate.done
:: Update the system and log it
:: details for parameters http://forums.wsusoffline.net/viewtopic.php?f=7&t=2691pushd %WPKGROOTPACKAGES%\wsusoffline\clientcmd /c cmd\DoUpdate.cmd /instie8 instie11 /updatercerts /verify /updatecpp /updatedx /instdotnet4 /updatetsc /instofc /instofv >%SystemDrive%\netinst\wpkg\offlineupdate.logpopd %WPKGROOT%\wsusoffline\clientdate /T >%SystemDrive%\netinst\wpkg\ctupdate.done</source>
if %errorlevel% equ 0 (
date /T >%SystemDrive%\netinst\wpkg\ctupdate.done
exit /b 0
)
ctcheck.js:<source lang="javascript">//delete ctupdate.done if a : return reboot is scheduledrequired exit code var WshShell = WScript.CreateObject("WScript.Shell");var fso = WScript.CreateObject("Scripting.FileSystemObject"); var ForReading = 1;var BasePath = WshShell.ExpandEnvironmentStrings("%SystemDrive%\\netinst\\wpkg\\");var LogFilePath = BasePath + 'offlineupdate.log';var CtupdatePath = BasePath + 'ctupdate.done';var LastLine = ''; String.prototype.trim = function() { return this.replace(exit /^\s+|\s+$/g, ''); } try { var f = fso.OpenTextFile(LogFilePath, ForReading); while (!f.AtEndOfStream) { var r = f.ReadLine(); //ignore last lines that are blank if (r.trim() != '') { LastLine = r; } } if (LastLine.search(/reboot/i) != -1) { fso.DeleteFile(CtupdatePath,true); }}catch (e){ WScript.Quit(1);}b 3010
</source>
 
 
Delphi source code for ctcheck.exe (ctcheck.dpr)(from previous version):
<source lang="pascal">
program ctcheck;
{$APPTYPE CONSOLE}
{
This program loads the ctupdate log file, then checks for the word "reboot" in the last non-empty line.
If the word "recall" is found it then deletes the "ctupdate.done" file, so that wpkg will run ctupdate again.
}
uses Windows,classes,sysutils;
 
function GetDrv(): string;
const
s = 'SYSTEMDRIVE';
var
BufSize: Integer;
begin
BufSize := GetEnvironmentVariable(PChar(s), nil, 0);
if BufSize > 0 then
begin
SetLength(Result, BufSize - 1);
GetEnvironmentVariable(PChar(s),
PChar(Result), BufSize);
end
else
Result := '';
end;
 
var
s:String;
fpath:String;
sl:TStringList;
begin
sl := TStringList.Create;
try
fpath := getDrv() + '\netinst\wpkg\';
sl.LoadFromFile(fpath + 'offlineupdate.log');
while(sl.Count > 0) and(trim(sl[sl.Count -1]) = '')do
sl.Delete(sl.Count -1);
if(sl.Count > 0) then
begin
s := sl[sl.Count -1];
if(AnsiPos('reboot', LowerCase(s)) > 0)
then
begin
if not(DeleteFile( fpath + 'ctupdate.done')) then Halt(1);
end;
end
else Halt(1);
except
end;
sl.Free;
end.
</source>
 
 
== Older solution without an exe file: ==
12
edits