Difference between revisions of "Installation instructions - mixed environments"

From WPKG | Open Source Software Deployment and Distribution
Jump to: navigation, search
 
(Files)
Line 26: Line 26:
 
   update-wpkg.bat - A script run by wpkg every time that updates invoke-wpkg.js
 
   update-wpkg.bat - A script run by wpkg every time that updates invoke-wpkg.js
 
   srvany.exe - The Microsoft file to allow any program to run as a system service
 
   srvany.exe - The Microsoft file to allow any program to run as a system service
   instserv.exe - The Microsoft file to install a system service
+
   instsrv.exe - The Microsoft file to install a system service
 +
  instserv.exe - The Microsoft program to get service stati (note, this has an E that instsrv does not have. it was also released one tools kit earlier)
 
   scripten.exe - The updated Windows script host
 
   scripten.exe - The updated Windows script host
  
Line 127: Line 128:
 
         }
 
         }
 
  }
 
  }
 
  
 
== Update wpkg packages.xml entry ==
 
== Update wpkg packages.xml entry ==

Revision as of 17:31, 27 February 2007

These instructions are based off Using srvany to create a system service but a bit more in-depth.

This is used in a mixed Windows2000/XP environment with both desktops and laptops (with wifi). Since the laptops don't usually have a wifi connection when they first start up, I had to write a script that would delay running wpkg until a connection was available.


Basic operation

Though it's a bit messy, all my wpkg files (listed above) are in \\server\software, as well as all my installation packages (they are actually in subdirectories below that). Again, I've had wpkg installed for a long time, thats the way it was originally setup.

Install wpkg by running \\server\software\install-wpkg.js. This copies over srvany.exe, instserv.exe and invoke-wpkg.js to the System32 directory. It then installs Windows Script Host (scripten.exe), and installs a service for "Windows Packager". (I use Srvany to invoke wpkg just because I've always done it that way, it would be possible to use these instructions to do it another way. Not that it makes a big difference, but my server is a Debian box running Samba.)

The "Windows Packager" service runs the invoke-wpkg.js in the local System32 directory, which keeps trying to ping the server until it either connects (in which case it starts wpkg.js), or runs into the maxRetries value (in which case it silently gives up). This means someone can log into a laptop while out of the office, and when they come in (assuming invoke-wpkg hasn't given up yet), it will run the wpkg installer.

One of my services also runs update-wpkg.bat every time wpkg runs (see below), which means if I've made any changes to the invoke-wpkg.js script, they get copied over.

I'm also using the Web interface to configure wpkg, but that's not a requirement for this setup.

Files

I have the following scripts installed in a network share:

 wpkg.js - The main wpkg script
 invoke-wpkg.js - The script that invokes wpkg, which lives on the client system
 install-wpkg.bat - The wpkg installer
 install-registry.js - A script invoked by the installer
 update-wpkg.bat - A script run by wpkg every time that updates invoke-wpkg.js
 srvany.exe - The Microsoft file to allow any program to run as a system service
 instsrv.exe - The Microsoft file to install a system service
 instserv.exe - The Microsoft program to get service stati (note, this has an E that instsrv does not have. it was also released one tools kit earlier)
 scripten.exe - The updated Windows script host


We are using the srvany.exe and instsrv.exe programs included with the Windows 2000 Resource Kit to install the wpkg.js script with the /synchronize /quiet options as a system service.

srvany.exe and instsrv.exe programs cannot be distributed along with this software for licensing reasons. However, you can find links in the download section.


install-wpkg.bat

You need to modify the \\server\software path to fit your environment.

 @echo off
 copy \\server\software\srvany.exe %SystemRoot%\System32
 copy \\server\software\instsrv.exe %SystemRoot%\System32
 copy \\server\software\invoke-wpkg.js %SystemRoot%\System32
 instsrv "Windows Packager" "%SystemRoot%\System32\srvany.exe"
 \\server\software\scripten.exe /Q /R:N
 wscript.exe \\server\software\install-registry.js
 net start "Windows Packager"

install-registry.js

 var WshShell = WScript.CreateObject("WScript.Shell");
 var srvKey = "HKLM\\SYSTEM\\CurrentControlSet\\Services\\Windows Packager\\Parameters\\";
 var appKey = srvKey + "Application";
 var parKey = srvKey + "AppParameters";
 var srvPath = WshShell.ExpandEnvironmentStrings("%SystemRoot%") + "\\System32\\wscript.exe";
 var srvArgs = WshShell.ExpandEnvironmentStrings("%SystemRoot%") + "\\System32\\invoke-wpkg.js";
 WshShell.RegWrite(appKey, srvPath, "REG_SZ");
 WshShell.RegWrite(parKey, srvArgs, "REG_SZ");

update-wpkg.bat

You need to modify the \\server\software path


 @echo off
 copy \\server\software\invoke-wpkg.js %SystemRoot%\System32

invoke-wpkg.js

You need to update all the variables at the top. The wpkgRoot and software variables set the WPKGROOT and SOFTWARE environment variables like the wpkg-start.bat.examples file distributed with wpkg.

 /*******
  * Invoke wpkg.js script
  * Waits for a connection to the server, then starts wpkg.
  * Good for laptops, or any other system with unstable connectivity.
  * (c)2006 Greg MacLellan
  */
 
 // the hostname or IP to ping
 var host = "server";
 // the location of wpkg.js. This will become the %WPKGROOT% environment variable
 // Remember to escape backslashes! (eg, \\server\share becomes "\\\\server\\share")
 var wpkgRoot = "\\\\" + host + "\\software";
 // The software root, this will just become the %SOFTWARE% environment variable
 var software = wpkgRoot;
 // Parameters to pass to wpkg
 var wpkgParams = "/synchronize /quiet ";
 // The wait time between ping tries
 var waitTime = 10000;
 // The maximum number of times to try before giving up
 // 0 to never give up.
 var maxTries = 999;
 
 
 
 /*****************
  Do not edit below this line
  *****************/
 
 var wpkgBin = wpkgRoot + "\\wpkg.js";
 
 // setup wsh objects
 var shell = WScript.CreateObject("WScript.Shell");
 var env = shell.Environment("PROCESS");
 
 // setup env variables
 env("WPKGROOT") = wpkgRoot;
 env("SOFTWARE") = software;
 
 var numTries = 0;
 while ((maxTries <= 0) || (numTries < maxTries)) {
 
         if (maxTries > 0) numTries++; // only increment if there's a limit
 
         var code = shell.Run("ping " + host + " -n 1", 0, true);
         if (code == 0) {
                 // connected
                 WScript.Sleep(2000);
                 // wait 2 seconds, and start wpkg.js
                 shell.Run(wpkgBin + " " + wpkgParams);
                 break;
        } else {
                 WScript.Sleep(waitTime);
        }
}

Update wpkg packages.xml entry

 <package id='update_wpkg' name='Update wpkg invocation script' revision='1' priority='20' reboot='false' >
    <install cmd='%SOFTWARE%\update-wpkg.bat' />
 </package>

Misc

Please update this page with any additional information or fixes.