Installation instructions - advanced

From WPKG | Open Source Software Deployment and Distribution
Jump to: navigation, search

If you don't need such customized or advanced installation instructions, you can use an easy to use WPKG Client.


Contents

[edit] Starting WPKG using Windows Task Scheduler

cscript \\server\wpkg\wpkg.js /synchronize /quiet /nonotify

This will create a scheduled job file, which you can copy to all other machines on the network (but you will have to renew credentials, as they are not stored in this file).

Alternatively, you may add a scheduled task from a command line (or during an Unattended install):

schtasks /create /tn wpkg /tr "\\server\wpkg\wpkg-start.bat" /sc onstart /ru domain\administrator /rp password

schtasks utility will work from the command line only in Windows XP or higher. If you have Windows 2000, and would like to install WPKG "silently", please see this page: http://www.windowsitpro.com/Article/ArticleID/25186/25186.html?Ad=1

Note that system commands in Windows are *incompatible* in different language versions of Windows! I'm not joking now!

For example, in German version of Windows, this command would look like that (note the /sc switch):

schtasks /create /tn wpkg /tr "\\server\wpkg\wpkg-start.bat" /sc beimstart /ru domain\administrator /rp password

If you're not sure, consult schtasks help:

schtasks /?


[edit] Starting WPKG using Samba, winexe and preexec/postexec directive in smb.conf

It is possible to start WPKG using winexe with Samba and some custom scripts defined in postexec and/or preexec in smb.conf - see WPKG with winexe.

[edit] Starting WPKG using Active Directory client

Basically, you don't have to configure anything on the client, because everything was configured on the Active Directory server (see above - Server side).

One thing you might need, is cscript binary - it is not shipped with Windows 2000, so you may have to add it to your clients (see above).

See also WPKG with Active Directory for a description with screenshots.

[edit] Starting wpkg using cygrunsrv.exe

An easy way to start WPKG as a service is to use cygrunsrv.exe from Cygwin.
You don't need to install Cygwin, it's enough if you copy cygrunsrv.exe binary and cygwin1.dll library.
Download: cygrunsrv.exe and cygwin1.dll

With cygrunsrv, it's easy to start WPKG as any user you want (SYSTEM, local administrator, domain administrator, (Limited/Restricted?), etc.)

For cygrunsrv usage, see cygrunsrv --help.

You can get cygwin1.dll from any Cygwin mirror, it's a compressed file located in the cygwin/release/cygwin directory (for example, cygwin-1.5.19-4.tar.bz2).
Cygrunsrv is similarly located in cygwin/release/cygrunsrv (for example, cygrunsrv-1.16-1.tar.bz2).

Here's one working example:

cygrunsrv -I wpkg -p '/cygdrive/c/WINDOWS/system32/cscript.exe' -a'c:\wpkg\wpkg\wpkg.js /quiet /synchronize' -c '/home/Administrator/wpkg/wpkg'
cygrunsrv -S wpkg

Those arguments are:

-I [name] 
Install a service named [name]. In this example, we're calling it wpkg.
-p [/path/to/executable] 
Path to the command to run -- in this case, cscript.
-a [arguments to executable] 
Arguments for the executable -- in this case, the path to wpkg.js and how we want it to run.
-c [directory] 
Go to this directory before starting the program.
-S [name] 
Start the service.

There are a few things to note:

[edit] Starting WPKG using srvany to create a system service (advanced)

All you have to do is to login to your Windows box, and issue these commands as Administrator - you can put them in one file which we call wpkg-install.bat:

Here is a sample wpkg-install.bat file - the sum of steps 1-8 described below. You may want to change some paths of course.

 SET SRVPATH=\\server\wpkg\files
 copy %SRVPATH%\srvany.exe %SystemRoot%\System32
 copy %SRVPATH%\instsrv.exe %SystemRoot%\System32
 instsrv "Windows Packager" "%SystemRoot%\System32\srvany.exe"
 %SRVPATH%\scripten.exe /Q /R:N
 cscript.exe %SRVPATH%\install-service.js
 net start "Windows Packager"


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.

It is quite easy to implement this yourself (for the impatient, all commands shown are able to be copy and pasted, or they're available as downloads below):

copy \\server\wpkg\files\srvany.exe %SystemRoot%\System32
copy \\server\wpkg\files\instsrv.exe %SystemRoot%\System32
instsrv "Windows Packager" "%SystemRoot%\System32\srvany.exe"

This creates the Windows service called "Windows Packager". It is however not yet started.

\\server\wpkg\files\scripten.exe /Q /R:N

This makes it install quietly and not reboot.

HKLM\System\CurrentControlSet\Services\Windows Packager\Parameters\Application
HKLM\System\CurrentControlSet\Services\Windows Packager\Parameters\AppParameters

The Application key specifies the full path to the executable that the service will run at boot. This is because we do not launch the wpkg.js file, we launch the Windows Scripting Host (cscript.exe) and instruct it to launch the wpkg.js file. Set the Parameters key to:

\\server\wpkg\wpkg.js /synchronize /quiet /nonotify

This instructs cscript.exe to run the wpkg.js script, which is placed on the network share, with the two options shown. It will synchronize the system on boot, logging errors quietly.

net start "Windows Packager"


To sum up, we have two files needed to install WPKG on a given Windows machine: wpkg-install.bat, which copies all needed files, and install-service.js (started within wpkg-install.bat), which installs WPKG as a service in Windows registry - so that it could be launched each time the machine is booted. wpkg-install.bat needs to be run only once.


This is an example install-service.js file:

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\\cscript.exe"
var srvArgs = "\\\\server\\wpkg\\wpkg.js /synchronize /quiet";
WshShell.RegWrite(appKey, srvPath, "REG_SZ");
WshShell.RegWrite(parKey, srvArgs, "REG_SZ");


Running the wpkg-install.bat file on a new system will now set up and run WPKG! Running this wpkg-install.bat file as part of your Windows install answer file is ideal.

Watch Windows reboot. Imagine you have over 20 packages being installed, half of which require a reboot. It's amusing to see Windows reboot itself for 30 minutes installing stuff.


[edit] Starting WPKG with a system service, in a mixed environment (advanced)

See Installation instructions - mixed environments

Personal tools
Namespaces
Variants
Actions
Navigation
ideas?
Toolbox