#101620 - 2003-05-30 12:57 AM
Excluding workstations for software install
|
Grasshopper75
Getting the hang of it
Registered: 2002-01-15
Posts: 99
Loc: Melbourne, Australia
|
I need to deploy IE6 SP1 to 500 PCs though there are some machines that cannot be included in the update as they are running apps which do not currently support IE6 SP1.
I want to write a script that excludes these PCs based on @WKSTA and was wondering how I can go about it. There are about 20 PCs out of a total of 500 that need to be excluded.
Any ideas ?
Grasshopper75
|
Top
|
|
|
|
#101621 - 2003-05-29 01:00 PM
Re: Excluding workstations for software install
|
Howard Bullock
KiX Supporter
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
An 'IF' comes to mind.
code:
if @wksta<>"computer1" and @wksta<>"computer2" and @wksta<>"computer3" and ...
Run update endif
|
Top
|
|
|
|
#101622 - 2003-05-29 01:03 PM
Re: Excluding workstations for software install
|
Grasshopper75
Getting the hang of it
Registered: 2002-01-15
Posts: 99
Loc: Melbourne, Australia
|
I was wondering if there is a 'cleaner' way of doing it rather than IF statements.
|
Top
|
|
|
|
#101623 - 2003-05-29 01:06 PM
Re: Excluding workstations for software install
|
Radimus
Moderator
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
$NotThesePCs='computer1 computer2 somepc anotherpc etc'
if not instr($NotThesePCs,@wksta) ;install sp1 endif
|
Top
|
|
|
|
#101624 - 2003-05-29 01:13 PM
Re: Excluding workstations for software install
|
Grasshopper75
Getting the hang of it
Registered: 2002-01-15
Posts: 99
Loc: Melbourne, Australia
|
Excellent.. I knew I would be using an InStr somewhere but just didn't have the brains to figure it out today.
Quick responses is what I love about this board.. you can have a bad day but still get to where you need to be.
Thanks.
|
Top
|
|
|
|
#101625 - 2003-05-29 01:52 PM
Re: Excluding workstations for software install
|
Howard Bullock
KiX Supporter
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Just be careful with that approach. You will get incorrect results if computer names are like:
"sam1", "sam11" and so on.
|
Top
|
|
|
|
#101626 - 2003-05-29 01:53 PM
Re: Excluding workstations for software install
|
Glenn Barnas
KiX Supporter
Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
|
This might be a good time to point out an InStr trick or two.
In Radimus' example, the spaces between the names are not required except to improve readability. It would work exactly the same with or without the spaces.
If every entry is the same length, the position can relate the name to a numeric position. This is useful in argument and menu parsing, or - in your case - performing special tasks on a machine based on information in an array.
For example, take these five names: Tom, Mary, Sally, Peter, John. The longest is 5 chars, so that's our "baselength. Create a string with each name padded with spaces to the baselength. In this example, I'll create an array of "ages" that associate with each name. code:
$Name = 'Sally' ; name to compare $Names = 'Tom Mary SallyPeterJohn ' $Ages = 22,19,27,24,26 ; Position returned, less 1, makes value Zero-Based $Pos = InStr($Names, $Name) - 1 If Position is -1, it wasn't found - zero or greater is OK If $Pos >= 0 ; divide by the baselength to find the ID $ID = $Pos / 5 ? $Name + ' is ' + $Ages[$ID] + ' years old! (ID is ' + $ID + ')' Else ? 'Invalid name specified!' EndIf
You can see how InStr returns a number (11 for Sally), which is reduced by one (now 10). Divide by the baselength (10/5=2) and it returns the array position or ID of the name found.
If you specify a name not in the list, InStr returns zero, which becomes -1 - easy to test for invalid names. In your case, an "invalid" name would actually get upgraded, and the others would either be skipped or have another action performed (as defined in the array, possibly, making each upgrade user/system specific).
Just a few more concpts on using InStr.. The code can be shortened a bit and functions combined, but I left it simple to illustrate the process.
Regards,
Glenn
_________________________
Actually I am a Rocket Scientist!
|
Top
|
|
|
|
#101627 - 2003-05-29 02:08 PM
Re: Excluding workstations for software install
|
Richard H.
Administrator
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
A couple more ways of skinning this one.
The first is very similar to the "InStr()" solution, but you won't need to worry about space characters in names, or short names that are present in longer name:
code:
$asIgnore="computer1","computer2","computer3",... If AScan($asIgnore,@WKSTA)<0 ; Do install EndIf
My preferred way however would be to use an ini file. This is more flexible and can be used over and over again.
Here is a simple application delivery mechanism. Have a file which has a section containing a list of software updates to apply.
Each software update has a section where you enter the names of any PC you want to explicitly ignore when you initially create the section. As PCs are updated they will write a timestamp to the file.
The file would look something like this:
quote: update.ini [SOFTWARE-LIST] IE60sp1=1 othersoft=1 ... [IE60sp1] PC38028=Ignore PC29381=Ignore PC02349=2003-03-01 12:30 PC91234=2003-05-16 11:08
Your update script will look like this:
code:
For each entry in SOFTWARE-LIST Is this PC in the software's section? YES IT IS: No update is required. Else NO IT ISN'T: Write the time and date to the software section using the PC name as a key Run the update script EndIf EndForEach
If you keep keep your update scripts in the same subdirectory and name them the same as the section you can automate this and not have to change your login script again.
As an added bonus you will get a record of which PCs have been updated, and when it happened.
The only drawback is that the ini file will get quite large over time, so you may need to remove sections when an update has been rolled out.
|
Top
|
|
|
|
#101629 - 2003-05-29 04:59 PM
Re: Excluding workstations for software install
|
Sealeopard
KiX Master
Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
|
If you have a defined delimiter, then you should ratehr use the SPLIT function, e.g.
code:
$exclude='tom,mary,sally,peter' $exclude=split($exclude,',') if ascan($exclude,$name)+1 ;name is in exclude list endif ; or if ascan($exclude,$name)=-1 ;name is not in exclude list endif
_________________________
There are two types of vessels, submarines and targets.
|
Top
|
|
|
|
#101630 - 2003-05-29 07:36 PM
Re: Excluding workstations for software install
|
NTDOC
Administrator
Registered: 2000-07-28
Posts: 11623
Loc: CA
|
Yes Richard's concept is good, except that it also leaves room for the ever present file locking issue. If done during logon, could present an issue. If the machine could not get exclusive lock on the file, and you are set to have your systems wait for logon to process before loading the desktop. Example of 2,000 systems trying to write to that file... If it took 3 seconds or 30 minutes to get exclusive lock for writing, that client could not complete the logon until it wrote to the file.
Granted one would assume that on a fast network all 2,000 could complete an INI update within a couple minutes or so, but still a potential issue.
This is good stuff, but looking more and more like a KiX Golf game only geared towards best approach instead of least amount of code.
Where's LONKERO and his ideas? I'd think he would love to jump on this one as well.
|
Top
|
|
|
|
#101632 - 2003-05-30 10:03 AM
Re: Excluding workstations for software install
|
Richard H.
Administrator
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
quote: it also leaves room for the ever present file locking issue
Theoretically that is true, but in practice how likely is it to cause a problem?
If it is a real concern then the fix is simple - rather than a software section keyed by the update name, have a status file for each PC which has an entry for each update in a similar form to that described above. You now have a simple software update file: quote: update.ini [SOFTWARE-LIST] IE60sp1=1 hotfixQ12345=1 ...
and for each PC there will be a status file: quote: PC02468 [UPDATE-STATUS] IE60sp1=Ignore hotfixQ12345=2003-05-30 09:04
Tip: Use a significant part of the workstation name (say the last two digits) to identify a subdirectory for the PC status files. This will stop the number of directory entries getting too large and causing long directory scans.
Advantages are:
- The status files are very small and quickly scanned/updated
- A lock on an individual workstations file will not hold up anyone else
- The status file can be used for recording all manner of useful information about the workstation above and beyond the status of software roll-outs.
Disadvantages are:
- Only the one really, which is that if you want to disable the update for 100 PCs, you have 100 ini files to edit or create
Of course the overhead of editing many files can be avoided by creating a simple HTML or KiXforms front-end and automating the update.
|
Top
|
|
|
|
#101633 - 2003-05-30 10:18 AM
Re: Excluding workstations for software install
|
Radimus
Moderator
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
look at the UpdateApp() udf I wrote a long time ago...
It maintains in the registry of the target PC a handy list of updates that I deploy via script and when they are installed. I prefer to read the registry for the specific changes made by the app's install, but this makes for a good, quick index by keeping all such info in one place.
|
Top
|
|
|
|
#101634 - 2003-05-30 10:39 AM
Re: Excluding workstations for software install
|
Richard H.
Administrator
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
The problem with storing the information on the PC is that you cannot do it unless the PC is connected and powered on.
In this specific case where you want to exclude PCs from the updates, you must use a centralised solution.
Additionally when you want to check the status of the PC you need it to be switched on and available - you cannot read the registry of a laptop which is disconnected from the network
It raises a good point though. The update mechanism should check for a (registry?) key and reset the status' if not present. This would catch for example a PC which is re-imaged.
|
Top
|
|
|
|
#101635 - 2003-05-31 12:28 AM
Re: Excluding workstations for software install
|
Grasshopper75
Getting the hang of it
Registered: 2002-01-15
Posts: 99
Loc: Melbourne, Australia
|
We write reg keys in HKLM and HKCU depending on what we are installing whether it is user specific or machine specific. As my IE6 update will be machine specific I am intending on writing a reg key to HKLM after the update but need to included the exceptions list in my script also.
There is only ever going to be a very small amount of exceptions so maintaining either the script or an INI file is not too much of any issue, its more deciding on the best one to use. I would like to use the script and/or reg keys where ever possible.
Grasshopper75
|
Top
|
|
|
|
#101636 - 2003-05-30 01:53 PM
Re: Excluding workstations for software install
|
Grasshopper75
Getting the hang of it
Registered: 2002-01-15
Posts: 99
Loc: Melbourne, Australia
|
This is becoming frustrating.. am I missing something or does Ascan not work as it should ?
code:
$IE6SP1Exceptions='Computer1','Computer2' $x=AScan(IE6SP1Exceptions,@WKSTA) If $x=-1 MessageBox("Install IE","Test") Else MessageBox("Do not Install IE","Test") EndIf
Grasshopper75
|
Top
|
|
|
|
#101637 - 2003-05-30 02:13 PM
Re: Excluding workstations for software install
|
Richard H.
Administrator
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
It works fine - note, it is only a recent addition to KiXtart.
code:
"KiXtart version: "+@KIX+@CRLF $aIgnore='abc','def','ghi' $s='def' If AScan($aIgnore,$s)>=0 $s+" is in the array." Else $s+" is not in the array" EndIf @CRLF $s='foo' If AScan($aIgnore,$s)>=0 $s+" is in the array." Else $s+" is not in the array" EndIf @CRL
Correctly ouputs:
code:
KiXtart version: 4.20 def is in the array. foo is not in the array
|
Top
|
|
|
|
#101638 - 2003-05-30 02:56 PM
Re: Excluding workstations for software install
|
Grasshopper75
Getting the hang of it
Registered: 2002-01-15
Posts: 99
Loc: Melbourne, Australia
|
I figured it out but may have found a bug in the process. It seems my variable $IE6SP1Exceptions is too long, I shortened it to $Exceptions and it now works fine.
Grasshopper75
|
Top
|
|
|
|
#101639 - 2003-05-30 03:00 PM
Re: Excluding workstations for software install
|
Richard H.
Administrator
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
...or it could just be that you were missing the "$" from the front of the variable in your AScan()
|
Top
|
|
|
|
Moderator: Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart
|
1 registered
(Allen)
and 466 anonymous users online.
|
|
|