WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: TSFleming on February 15, 2015, 04:44:20 PM

Title: Location based software installation
Post by: TSFleming on February 15, 2015, 04:44:20 PM
Iââ,¬â,,¢m trying to create a script to install software based on location, and location is determined via hostname.  Letââ,¬â,,¢s say I have 3 computer naming conventions, for this example; DT-Chicago-123, DT-London-123 & DT-Tokyo-123.  Iââ,¬â,,¢m getting the hostname from the registry and am setting a variable based on that;

HostName = RegQueryValue(@REGMACHINE, "SYSTEM\CurrentControlSet\Services\Tcpip\Parameters[Hostname]")

Next I tried to determine which hostname was returned in order to specify what software to install;

CHI = strindexNC(HostName, "* Chicago *", 1, @fwdscan)
LON = strindexNC(HostName, "* London *", 1, @fwdscan)
TOK = strindexNC(HostName, "* Tokyo *", 1, @fwdscan)
If CHI == @TRUE then
else
If LON == @TRUE then
else
If TOK == @TRUE then

Obviously the above is incomplete/incorrect which is why Iââ,¬â,,¢m posting.  What would be easiest (correct) way to accomplish this?

Any assistance is appreciated.
Title: Re: Location based software installation
Post by: stanl on February 16, 2015, 03:47:13 AM
Maybe drop the * in the search.
Title: Re: Location based software installation
Post by: TSFleming on February 16, 2015, 08:57:53 AM
Thanks, that seemed to have worked.  I also found that I could simply use the following syntax to get the desired results;

If strindexNC(HostName, "Chicago", 1, @fwdscan) then
If strindexNC(HostName, "London", 1, @fwdscan) then
If strindexNC(HostName, "Tokyo", 1, @fwdscan) then

:)
Title: Re: Location based software installation
Post by: stanl on February 17, 2015, 10:12:50 AM
Yes, that would have been the correct method if you removed the * as I suggested.