More on SBS login scripts

This post comes from an SBS user (thanks, TK!).


Because there have been various requests for login script help, I wanted to post something that may help those who aren’t so familiar with writing a batch file or login script.

DISCLAIMER: I’m not an instructor, I haven’t written any books, I don’t write code for a living, and there may be other ways to accomplish the same thing as I have written.  This is intended to help others so please keep your opinions to yourself unless you have something constructive to add that will benefit others.  Additionally, this example script is intended for tutorial purposes and will need ‘tweaked’ to suit your environment.  I take no responsibility for the use of this script in a production environment.

NOTES: There are tremendous amounts of information on the Internet and in books on how to write scripts, what good practices are, and what variables can be used in a login script (batch file).  This should be enough to get  the average person going in short order.  If anything is unclear, or if you have questions, please post them.  Remember, you will need to modify this script for your server name, network share names, drive letters you require, printer names, etc.

Okay, with BS out of the way, let’s get going. 


First, you can find your default login script by clicking Start – Run, type \\ServerName\netlogon, click OK.  This will open a folder with a batch file called SBS_LOGIN_SCRIPT.bat.  Using Notepad, WordPad, or your favorite text  editor open this file (note: you should be able to right-click the file and select edit from the context menu).  This file generally includes only one line used for SBS client setups.  Do not remove this line!  It can be moved around within the script, but leave it intact.  If you don’t already know it, this line will tell you the name of your server.

Now, following will be a clean version of my sample login script followed by a sample with notes.  My notes will start with the “Note:” to help you distinguish the difference.  If this helps even one person, it was worth the time.  If you have further questions, please post them for all to learn from. Enjoy!
-TK  M/T Box Computers

<CLEAN LOGIN SCRIPT>
@echo off
rem   ==================================================
rem
rem   Title: Login Script
rem   Author: Your Name
rem   Date: Self-explanatory
rem   Description: Network Login Script
rem
rem ==================================================

:SBS_SETUP
rem Default sbs2k3 client setup
\\ServerName\Clients\Setup\setup.exe /s ServerName

:MAPDRIVES
rem Connect network drives
if exist f:\*.* net use f: /d
net use f: \\ServerName\ShareName /persistent:no
if exist g:\*.* net use g: /d
net use g: \\ServerName\applications /persistent:no
if exist h:\*.* net use h: /d
net use h: \\ServerName\%username% /persistent:no

:PRINTERS
rem Connect network printers
net use lpt1: \\ServerName\Printer1ShareName /persistent:no
net use lpt2: \\ServerName\Printer2ShareName /persistent:no

:END
</CLEAN LOGIN SCRIPT>


<COMMENTED LOGIN SCRIPT>
Note: The word ‘REM’ is a way to add a remark to your batch file (login script).  It is a good idea to use remarks throughout your login script. This will help later when troubleshooting why the login script is written the way it is.  You should also document dates of changes and why.

Note: The command ‘ECHO’ can be used to turn display on and off.  ‘ECHO’ followed by words will display those words on the screen.  ‘ECHO OFF’ will suppress all display until ‘ECHO ON’ is issued.


Note: The @ sign in front of ‘ECHO OFF’ says to not display this line also.

@echo off
rem   ==================================================
rem
rem   Title: Login Script
rem   Author: Your Name
rem   Date: Self-explanatory
rem   Description: Network Login Script
rem
rem ==================================================

Note: The use of the colon ‘:’ followed immediately by a word designates the following lines as a section or routine within your script.  This allows you to move back and forth within the login script.  This isn’t normally necessary, but I found it helpful to form good script writing habits early on.  A batch file will normally flow from top to bottom 
executing every line it comes to that is not a remark line, and that is an actual command.  You can skip sections by using the ‘GOTO’ command.  Often times I will check for the existence of the drive mappings after they should have completed.  If they do not exist I will send the user to an error message section letting them know something failed, with instructions to reboot and/or contact their IT support.  If you would like an example of this also, let me know and I will post it.

:SBS_SETUP
rem Default sbs2k3 client setup
Note: Leave this line intact somewhere near the head of your script.  As 
you see here, this is the first actual line that executes in this script.
\\ServerName\Clients\Setup\setup.exe /s ServerName>

:MAPDRIVES
rem Connect network drives
Note: Tests for and deletes drive mapping if it exists (ensures drive letter isn’t erroneously mapped elsewhere).
if exist f:\*.* net use f: /d
> Note: Correctly maps drive letter to network share.
> Note: Be sure to modify for your correct server name.
net use f: \\ServerName\ShareName /persistent:no
if exist g:\*.* net use g: /d
net use g: \\ServerName\applications /persistent:no
if exist h:\*.* net use h: /d

Note: I have used the variable ‘UserName’ below.  The system will read this as the login name of the user.  If you setup a user share with each user’s login name, this line will correctly map a home drive for each user based on their login name.  Don’t forget to set security and permissions on the user shares you setup.
net use h: \\ServerName\%username% /persistent:no

:PRINTERS
rem Connect network printers
Note: This will map your network printers to LPT ports.  This is normally only necessary for older legacy (read: DOS) programs.
Note: Be sure to modify for your correct server name.
net use lpt1: \\ServerName\Printer1ShareName /persistent:no
net use lpt2: \\ServerName\Printer2ShareName /persistent:no

:END
</COMMENTED LOGIN SCRIPT>

Tablet PC’s anyone?

Here are some recent, random thoughts from some of the SBS MVP’s on which tablet PC to get. First, some links: http://www.microsoft.com/windowsxp/tabletpc/evaluation/products.mspx 
http://www.microsoft.com/windowsxp/tabletpc/howtobuy/default.mspx
http://www.microsoft.com/windowsxp/downloads/tabletpc/experiencepack/default.mspx


1. Right now I’m torn between the Acer C110 and C300. I’m leaning towards the C110 (which is only 3.2 pounds!) and it has everything I want… but no integrated optical drive. Any recommendations (not necessarily within Acer)? Also, advice on where to get a good deal will be also appreciated it.

2. I just purchased a Fujitsu Stylistic 5020 Tablet, with the docking kit, 2GB Ram and the top processor.    It is quite light, and I have to say it is the best piece of equipment I have ever purchased. 


3. I really like the HP TC1100 I’m using. I added a gig of aftermarket RAM to it (was 512) and very happy with it. The slate is 3 lbs and with the keyboard it is at 4 or 4.1 lbs. I went with the HP because of the glass screen and smaller form factor (more like a pad of paper) than the larger Tablets with rotational screens.


4. I’ve got myself a Toshiba Portege M200 tablet – it’s fantastic.  I got 5hrs on a recent trip to Singapore on battery and it still had some to spare.  It’s light and fairly fast.  It’s not one to run VPCs on though – at least not multiple VPCs at the same time.


5. I got my TabletPC yesterday!!!! Fujitsu Lifebook T4000. Originally [I was going to] get an Acer C110, but it seemed impossible to get the one I wanted. [T]he new IBM/Lenovo X41 was pretty cool, but too expensive for me. Anyway, I think I got a good deal on a refurbished model-> Intel Centrino 1.8, 512MB ram, 60GB HD, Bluetooth, Firewire and built-in DVD+/-RW with a Port Replicator and a Car/Air charger for ~$1600 (with $100 off + 5% student discount). Most importantly its only 4.1 pounds and battery lasts 5 hours (which is a significant improvement over my current HP, 8.2lbs and less than 2hr running time J). I have only played with it for one day (and already upgraded the memory to 1.5GB) but it’s an impressive little machine.


6. FedEx delivered my new Acer TravelMate C314XMi today . . .   2.0 GHz Pentium M, 1 gig RAM, 100 GB HD, gigabit lan, etc. etc.  now its time to start playing and get everything loaded   J

2005-08-06 “(Listen) Do You Want to Know a Secret”

Sparks were flying this past week in Las Vegas as researcher Michael Lynn, just prior to giving a speech at the Black Hat security conference, quit his job, and then proceeded to change his speech to discuss a known flaw in Cisco routers, and actually demostrated how he could break into one —  within 5 seconds. The legal reps from all three parties scurried to make sure that Michael Lynn would not talk about his findings in the future. But the damage had been done.

<< Getting on my soapbox >>

Why do I bring this up? Some, but not many of us, even use Cisco routers in our SBS servers. But I betcha your bank that you do online business with does, as well as your ISP you use to connect to the Internet. I don’t wish anything bad to anyone, and I’m not here to judge whether Michael or Cisco did the right or wrong thing, but the fact of the matter is that there are companies that need to start stepping up, as Microsoft is trying to do, and address the security vulnerabilities in their products. Shame on everyone involved If its even partly true that this Cisco vulnerability was identified months ago, and nothing was done about it.

http://www2.nwfusion.com/columnists/2005/080105backspin.html
http://www2.nwfusion.com/news/2005/080105-blackhat.html

<< OK … I’m now getting off my soapbox>>

All of this leads me to my song of the week … from the Beatle’s … and, please remember, as with all my parodies, this is done in jest …

(Listen) Do You Want to Know A Secret
aka (Listen) Do You Want to Know an Exploit

WAV:
http://www.iqm.ro/beatles/beatles/doyouwan.wav

You’ll never know how much we really hacked you
You’ ll never know how much harm we really did …

Listen, do you want to know an exploit,
Do you promise not to tell,
Who-o-o-oh….
Closer, I’ve just hacked into your router
Caused a buffer over-flo-o-ow
I’ve just shut you down, o-o-o….

Cisco, do you want to know the truth now
Do you promise you’ll tell all,
Who-o-o-oh….
Fix it! Let me shout it in your ears
Say the words you need to hear
I’ve just broken through, o-o-o….

I’ve known the exploit for a week or two
Now everybody knows, not just you

Listen, are you gonna fix that exploit
Do you promise you’ll be true,
Who-o-o-oh…
Hurry, let me whisper in your ear
Say the words you long to hear
“Here’s the patch for you”, o-o-o….


Kevin Weilbacher [SBS-MVP]
“The days pass by so quickly now, the nights are seldom long”

2005-07-31 “Summer In The City”

So, here we are at the end of July, which is important for several reasons. First, my wife and I celebrated our 32nd wedding anniversary this past week. Second, we’re half way through the summer heat and humidity of Florida weather. And third, we’re close enough to start our countdown to this year’s SMB Nation Conference, to be held in Redmond – see www.smbnation.com .

Speaking of the heat and humidity, let’s turn to a fun song from John Sebastian, and the Lovin’ Spoonfuls … originally released in late 1966!

Summer in the City

aka Spammers in my Server

 



(note: fast forward to about 1:06 into the file)

Hot town, spammers in my server
Disks have all crashed, and things aren’t any better
Still down, isn’t it a pity
Doesn’t seem to be any help in the city
All around, people looking half dead
Staring at their blank screens, hotter than a match head
 
But at night it’s a different world
Loadin’ patches, head’s in a swirl
Come-on come-on and work all night
Despite the heat it’ll be alright
And babe, don’t you know it’s a pity
That the days can’t be like the nights
And the hackers, in the city
And the spammers, what a pity
 
Cool time, evening in the city
Working so hard, the server’s looking pretty
Bad news, we found another bugger
Now I’m on the warpath, so they better take coverr
Till I’m wheezing like a bus stop
Running up the stairs, gonna throw it off the rooftop
But at night it’s a different world
Server’s fine, I’m out with my girl
Come-on come-on and work all night
Despite the heat it’ll be alright
And babe, don’t you know it’s a pity
That the days can’t be like the nights
And the hackers, in the city
And the spammers, what a pity

Hot town, summer in Seattle
Back of my neck, still dirty from the battle
Still down, spammers in the shadows
Doesn’t seem to be help from Gates or his pals
All around, people looking half dead
Pop-ups on their desktops, hotter than a match head
But at night it’s a different world
Scanning files, and lookin’ for those pearls
Come-on come-on and work all night
Despite the heat it’ll be alright
And babe, don’t you know it’s a pity
That the days can’t be like the nights
And the hackers, in the city
And the spammers, what a pity


Kevin Weilbacher [SBS-MVP]
“The days pass by so quickly now, the nights are seldom long”