Chris Erwin

Discrete and Discreet

September 17, 2008

Windows Vista and Non-Broadcasted SSIDs

Filed under: Computers,Technology,Windows — Chris Erwin @ 12:54 pm

When I told the teacher in charge of one of the laptop carts at the high school that I’d be taking 3 of his laptops and his access point because “the computers are set to connect to the access point, but they just won’t” he asked if I was going to put them in therapy.  I confirmed that I’d be setting them up in a circle for group therapy so we could work through their aversion to connecting the the WAP.  I was more correct in this than I had first thought.

Turns out there’s an extra check box in Vista’s wireless network profiles that says “Connect even if the network is not broadcasting” and sure enough our WAPs don’t broadcast their SSIDs.  Simple enough fix, and if you’ve found this via googling about why your Vista laptop won’t reconnect to your wireless network, you’re done.  I however have 120 laptops that have this setting.  Hmm.

For a simpler fix we now turn our attention to the Proxim AP-4000M, of which I have 9 to deal with.  Simple enough, but they don’t have the SSID broadcast setting in their web interface.  After about 20 minutes of perusing the manual, I found the telnet commands I needed.  I fired up putty and in no time had all 120 laptops working.  “show wif” lists your wireless profiles.  make note of the numbers and type “set wif # closedsys disable” for each number.  “reboot 0″ or power-cycle the access point.

“But Chris!” you say, “Isn’t broadcasting your SSID a bad idea?”  Well, you see we use WEP encryption with MAC filtering, which is about as secure as a 1-digit bike lock to someone who knows what they’re doing, not to mention the whole system is being replaced by a building-wide Cisco setup soon enough.  Not broadcasting your SSID is security through obscurity.  Besides, how else can you show off your clever network name?  Our home network is currently SPACEBALLS: The Router.

June 30, 2006

Wide-Spread File Deployment With VBScript

Filed under: Computers,Programming,Scripting,Technology,Uncategorized,Windows — Chris Erwin @ 4:27 pm

Quite often at work we need to deploy one or more files to large numbers of computers. The long way to do it is to manually copy to each computer through the network one at a time. When an entire school needs to be done, it gets very tedious. Another option is to set up a drag-and-drop event in Altiris Deployment Console, our deployment solution, which can then be deployed to an entire school in one shot. However, it can be annoying to set up a new event for every file that needs to be moved, and there are certain files it just doesn’t like to move (.url files for example).

Either my ‘hacker’ side who wishes to come up with creative solutions to problems, or my lazy side, led me to throw together a quick and dirty vbscript to take care of this. It had to be simple yet flexible enough that no code needs to be edited to change what files are being copied. The most challenging part was that I didn’t know anything about vbscript.

The reason I picked vbscript is because it can be executed on any Windows XP machine, so the work can be done from anywhere on the student VLAN. No compiling needed, and it’s more powerful than a batch file.

The script asks for four pieces of input. The file or files being copied, the directory on the remote computers to put the file in (same place on every machine), an input file containing a list of computers, and a log file to write to, so that we can manually hit any computer it missed.

Taking the input and copying the file are both very basic operations which anybody can learn to do with vbscript after a little googling. At the heart of the script is the LineParser function, which takes input from the computer name list and passes computer names to the CopyFile function. At first the computer name list file was just a list of full computer names, one per line, which were passed directly to the CopyFile function from the file system object. However, our computers are named schoolnumber-roomnumber-computernumber (##-[###|####]-##), so some loops should easily work. I then added the LineParser function to allow the input file to have one of three things on each line: a full computer name, a school number, or a room number and the number of computers in that room. Each line will either be ##-###-## or ## or ### ##. LineParser determines which of these three patterns is present on a line and acts accordingly.

If the line contains a school number (only two characters on the whole line):
If Len(LineReader)=2 then
SchoolNumber=LineReader
then the SchoolNumber variable is changed to that new school number. Any subsequent lines containing a room and number of computers will use that school number to construct computer names, until another school number line is encountered.

If the third character is a ‘-’ then the line must be a computer name. It is passed directly to the CopyFile function:
ElseIf Mid(LineReader,3,1)="-" then
FNameS = "\\" & LineReader & "\c$\" & MoveToPath
CopyFile(FNameS)

You can see the UNC path being built up from the rest of the user input.

If these two criteria are not met, then the parser assumes the line contains a room number and number of computers. If not, then the user constructing the input file screwed up, and I didn’t put any error protection in there for that so oh well. A loop then begins, passing computer names to the CopyFile function that are constructed using the room number and the last school number specified:

Else
     Room = Split(LineReader," ")     RoomNumber = Room(0)
     NumComps = Room(1)
     for i = 1 to NumComps
          if i < 10 Then
               iFixed = "0" & i
          Else
               iFixed = i
          End If
          CompName = SchoolNumber & "-" & RoomNumber & "-" & iFixed
          FNameS = "\" & CompName & "c$\" & MoveToPath
          CopyFile(FNameS)
     Next
End If

The vbscript function Split splits an input line at the delimiter given (space in this case) and tosses them into an array (so you end up with an array of words). The loop then builds computer names and passes them on. Fun stuff.

All of this results in allowing a flexible pseudo-language to be used to specify computers. an input file may look like this:
82
126 32
128 32
LIB 20
25-101-01
35-105-03
133 25
80
LIB 20
These 8 lines would result in the file(s) being copied to 131 computers. Note that the school number 82 persists past the two explicitly listed computers, until the school number 80 is specified.

The entire script can be found here. I plan to rearrange the if statement so that full computer names are the Else, so that any computer name can be used, not just those that follow the ##-… pattern. There are some other functions I’d like to add, but right now it does everything we need.

I learned two things in the two hours I spent doing it. I learned vbscript, and I learned that I don’t like vbscript. It is very inconsistent. It is certainly more powerful than batch programming, but doesn’t match perl, python, or any of the like for scripting. Oh well, it was fun.

Powered by WordPress