[wpkg-users] Set variable based on Computer Name
Rainer Meier
r.meier at wpkg.org
Fri Jan 6 00:24:40 CET 2012
Hi Michael,
On 06.01.2012 00:03, Michael MacKay wrote:
> I have 10 locations I am using WPKG with and use some syncing software to deploy
> the WPKG directory to all the locations. Currently, I have the WPKG Clients on
> each workstation have the %SOFTWARE% location variable and wpkg.js directed to
> the local server, so all the files in the WPKG directory are common across all
> locations.
>
> I would like to set it to allow a local initialization of wpkg.js but when I run
> it from a batch file it doesn't have the %SOFTWARE% variable so can't find the
> installers.
>
> I use a common hostname structure; Each office has a unique first four
> characters on all system, with the server having only the four characters. SO
> when I run this on any client it will pull the script.
>
> set SERVER=%computername:~0,4%
>
> cscript //%SERVER%/WPKG/wpkg.js /synchronize
>
>
>
> Unfortunately, it doesn't have the WPKG variable for the software path as that
> is in the WPKG Client. Is there a way to set a WPKG variable based on the first
> four characters of the hostname? Then I could build that into the package.xml
> and can run the wpkg.js without the client which would allow me to troubleshoot
> easier, as well as manually start wpkg to install on systems without rebooting.
> I am sure it wouldn't be hard, I just don't know javascript at all...
I am not sure if I fully understood your use case as I just skimmed your text.
If you call wpkg.js from script you might just set the SOFTWARE variable in the
script:
@echo off
set SERVER=%computername:~0,4%
set SOFTWARE=\\%SERVER%\share\software
cscript \\%SERVER%\WPKG\wpkg.js /synchronize
If you call wpkg.js by WPKG-Client, then just set SERVER and SOFTWARE variables
in WPKG client variable. Alternatively just configure WPKG client to run exactly
the script above from some share or the local drive. So just use WPKG-client to
do exactly the same thing as you would do manually.
If you need some variables set in packages then you might use WPKG 1.3.0 and
conditional values:
<variable name="SERVER" value="abcd">
<condition>
<check type="host" condition="hostname" value="^abcd" />
</condition>
</variable>
<variable name="SERVER" value="1234">
<condition>
<check type="host" condition="hostname" value="^1234" />
</condition>
</variable>
This will assign the value "abcd" on all hosts where the hostname starts with
"abcd".
It will assign the value "1234" if the hostname starts with 1234.
...
Like this you can set variables within a package, a profile or within host
assignment.
br,
Rainer
More information about the wpkg-users
mailing list