Link to home
Start Free TrialLog in
Avatar of devon-lad

asked on

SBS login script taking 3 attempts to complete all tasks successfully

Hi there,

I have a client with four sites.  SBS at site1, W2003 server at the other 3 as domain controllers.  Connected together via VPN.

I use the login script below to achieve the following things:

1.  Run the SBS client setup to configure Outlook and the network printers (Outlook 2003 is already installed on all PCs)

2.  Set the default printer for the client computer based on its subnet (and hence location).

3.  Copy desktop shortcuts to the user's desktop - I've specifically chosen to copy from the local server's netlogon folder just in case the VPN link is down.

4.  Finally map a drive to a DFS root

Here's what happens - you can assume that no user action is taken between each login.

1st time a user logs into a PC
Outlook not configured properly
Printers not installed
Shortcuts ok
Network drive ok

2nd time the user logs into same PC
Outlook configured properly
Printers installed but default printer not set

3rd time the user logs in
Default printer set

Anybody shed some light on why this is happening?

-----script start

\\SERVER1\Clients\Setup\setup.exe /s SERVER1

for /f "tokens=2 delims=:" %%a in ('ipconfig ^| find /i "IP Address"') do set IP=%%a

for /f "tokens=1-3 delims=. " %%a in ("%IP%") do set Subnet=%%a.%%b.%%c

if "%Subnet%"=="192.168.0" goto Site1
if "%Subnet%"=="192.168.1" goto Site2
if "%Subnet%"=="192.168.2" goto Site3
if "%Subnet%"=="192.168.3" goto Site4
goto end_setup


rundll32 printui.dll,PrintUIEntry /y /n \\\Laser-Site1
xcopy \\server1\netlogon\desktop\* "c:\documents and settings\%username%\desktop" /d /r /y

goto end_setup


rundll32 printui.dll,PrintUIEntry /y /n \\\Laser-Site2
xcopy \\server2\netlogon\desktop\* "c:\documents and settings\%username%\desktop" /d /r /y

goto end_setup


rundll32 printui.dll,PrintUIEntry /y /n \\\Laser-Site3
xcopy \\server3\netlogon\desktop\* "c:\documents and settings\%username%\desktop" /d /r /y

goto end_setup


rundll32 printui.dll,PrintUIEntry /y /n \\\Laser-Site4
xcopy \\server4\netlogon\desktop\* "c:\documents and settings\%username%\desktop" /d /r /y

goto end_setup


net use v: "\\domain.local\user documents"

-----script end
Avatar of devon-lad


Just realised for some reason the server names in the printer paths are missing - in the production script each printer is specified as \\server1\Laser-Site1 etc.
Avatar of Jeffrey Kane - TechSoEasy
I don't quite understand why you are doing this... do you realize that "\\SERVER1\Clients\Setup\setup.exe /s SERVER1" is actually doing most of this for you?

SBS will automatically configure Outlook as well as assign all network printers.  


Yes, I do realise I wrote...

"I use the login script below to achieve the following things:

1.  Run the SBS client setup to configure Outlook and the network printers (Outlook 2003 is already installed on all PCs)"

The point is that each user has to login twice before Outlook is configured properly.

The rest of the script that isn't working is for setting the default printer based on subnet...and this takes 3 goes before the default printer is set properly.
Okay... sorry, I answered too quickly... because the fact is that the logon script is used for much more than just configuring Outlook...

Anyhow... that aside, I would suggest that you do NOT include your other functions directly in the SBS_LOGON_SCRIPT.bat file.  Instead, create separate batch files that are stored in the same folder and use the CALL function within the SBS_LOGON_SCRIPT.bat file.  The reason for this is because there is no way to easily have the next step wait for a prior one to be completed, and I would guess they are trampling on eachother.

No problem, especially as it was you in a previous post that told that sbs setup script would configure Outlook.  ;o)

Anyway, as far as Outlook setup is concerned, if it is the case that later steps in the script are starting before previous steps are completed - this wouldn't affect Outlook set up would it?  The only part of the script that affects that is the first line.

Secondly, if I use CALL to run other batch files, there's still no way to know if the SBS setup has completed before the CALL to the other batch file is made.

I will give it a go though, see if it makes any difference.
Well, this is true... in http:Q_21971080.html I thought we had covered that.

As for using the CALL function... it's not so much a problem of waiting for the SBS setup to complete, as the other lines you have in the Batch File... when you have more than two additional lines in the SBS_LOGIN_SCRIPT.bat file, there is a strong possibility that they will not run.  Using the CALL funciton corrects this by forcing the focus to go back to the default logon script after running each new command.

If I view the command window as the script is running...I can see that it is correctly navigating to the correct site subroutine after the SBS setup is complete.  It gives printer related errors the first 2 times before finally succeeding in setting the default printer.  This would suggest that the additional commands are being run.

But printers aside, if I delete everything so that only the SBS setup line is left, there is still the same issue with Outlook i.e. first time the user logs in and runs Outlook, it goes through the setup wizard.  If they cancel this, log out, then back in again, they find that Outlook is correctly configured.
You don't really need to do this, by the way... printers are assigned to workstations through the SBS Server Management Console.

The Setup Wizard for Outlook should be allowed to run... but it doesn't have to.  it's just making sure that the user is using the most current version.

The printers are added to the directory using the SBS server management console.  But as far as I'm aware you can't use it to assign default printers to particular workstations - if you can, there's still the issue of laptops.

All printers in the directory are being added to all machines - but some errors getting the correct default one set.

However, I've opted for a bit of vbscript to do the printer bit - which seems to be working better than the printui.dll,PrintUIEntry interface.

So that just leaves the problem with Outllook.  My SBS_LOGIN_SCRIPT.bat file now only has 2 lines in it.  One that runs the SBS setup and one that calls the printer setup script.

But users are still experiencing the same problems.  It is fairly commonly known now throughout the company that when you log in to a PC for the first time you need to logout then back in again to get Outlook setup correctly.  While this is a solution of sorts, it's a bit annoying not to get it working properly.

When I say the setup wizard runs, I mean the user is asked for server type, server details etc. - not just talking about MS Installer running.

If the user is NOT a member of the local Administrators group you will experience this behavior.  But if they are a member of the local admins group then you shouldn't have to log back out and in.  A user is made a member of the local admins group automatically when you run the connectcomputer wizard to join the workstation to the network and assign the initial user.  If your users often use different machines, you may want to add the "Domain Users" group to the Local Administrators Group... thus granting everyone the rights to allow the Office Installer to continue on it's own.


Yes, all Domain Users are already local admins.
Okay, then what's the problem?  It seems that they are cancelling the setup wizard when they first log in?  They shouldn't do that... they should just allow it to continue.

If they continue with the setup wizard, Outlook asks them for their server details.  Fact is they all know them now.

But it should be automatically configured.

If they cancel the wizard, then log off and back in...Outlook is then configured automatically.

However, it may be that all this has been caused by a problem that's just been identified.  I noticed alot of NTDS KCC errors in the logs of the SBS server - had a check round and realised that the domain controllers weren't replicating properly.

Had Microsoft on the case for the past 24 hours - apparently DNS was in a bit of a mess.  I hadn't made any amendments to it...thought SBS handled all of this for you.  Anyway, the MS guy says he can't say how it got in that mess...but it was in a mess nevertheless.

Also, there were fragmented packets on the WAN links - so the MTU for AD replication had to be lowered on all servers.

Fingers crossed...everything APPEARS to be working fine now.

Okay, I didn't realize that it was asking for mailbox info.  But glad that you have things worked out.

Just to be sure though, check to make sure you don't have two versions of Outlook installed on your workstation.  This often happens when you install the entire Office Suite including Outlook and also have SBS install it.  Here's how to check:

If you look in add/remove programs, click on Office 2003's change button and see what modules are installed.  Then, do you also have a separate line for Outlook in add/remove programs?  If so, you need to uninstall one.  I'd suspect that perhaps the one SBS installed is in C:\Program Files\Microsoft Outlook instead of where Office normally resides which is C:\Program Files\Microsoft Office.

Hopefully this isn't the case and hopefully all is now well.


Avatar of DarthMod
Flag of United States of America image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial