Author Topic: Script to retreive and/or update sysinternals tools  (Read 16246 times)

Stéphane P.

  • Junior Member
  • **
  • Posts: 15
    • View Profile
Script to retreive and/or update sysinternals tools
« on: July 22, 2014, 21:59:30 »
I share my script in case of it can interest other people.
The need is to update "Process Explorer" tools from Sysinternals to the last version.
It verifies the registry to see if the EULA has been accepted. If it is the case, it retreives the running path to overwrite it if a newer version exists.
If no EULA, retreives the last version in a defined path.

The only possible problems is that live.sysinternlas.com may take a long time to respond.

Code: [Select]
// 191.236.128.229 = live.sysinternals.com
// Return Only wants "num"

@var $ProcExpOnlineVersion, $ProcExpLocalVersion;
@var $ProcExpOnlinePath, $ProcExpLocalPath;

@var $ExecutableName = "procexp.exe";
@var $ExeRegName = "Process Explorer";
@var $l, $o;


function GetOnlineVersion($ExecutableName)
{
 @var $Result
 $ProcExpOnlinePath = '\\191.236.128.229\Tools' ^ $ExecutableName;
 $ProcExpOnlineVersion = GetFileProp($ProcExpOnlinePath , "ExtendedProp.prodVersion");
 $Result= StrReplace($ProcExpOnlineVersion , "." , "" );
 return $Result;
}

function GetLocalVersion($ExeRegName)
{
 @var $Result
 @var $exists = RegKeyExists("HKCU","Software\\Sysinternals\\" + $ExeRegName );
 if( $exists == 1 )
 {
  $ProcExpLocalPath = RegValueGetSZ("HKCU","Software\\Sysinternals\\" + $ExeRegName, "OriginalPath");
  $ProcExpLocalVersion= GetFileProp($ProcExpLocalPath , "ExtendedProp.prodVersion");
  $Result= StrReplace($ProcExpLocalVersion, "." , "" );
  return $Result;
 }
 else
 {
  $ProcExpLocalPath = "C:\\Temp" ^ $ExecutableName;
  return 0;
 }
}

function CopySysTool()
{
 CopyFile( $ProcExpLocalPath , $ProcExpOnlinePath , "NODIALOG, OVERWRITE_ALL");
}

$o = GetOnlineVersion($ExecutableName);
$l = GetLocalVersion($ExeRegName);

if( StrCompareNoCase($l , "0" ) == 0 )
{
 CopySysTool();
}
else
{
 if($o > $l)
 {
  CopySysTool();
 }
}