The login script I'm using below is not working on windows 7. Not of my drives are mapped. Does any know what is the issue. Currently I'm the only one using Windows 7 so it's not an issue. But I need to get it fixed and also fixed in a way that it'll work for both XP and 7 as I imagine I'll be using a mixed environment for quite some time.

THANKS!

@echo off
cls

REM LOGIN.BAT
REM Default Login Script
REM
REM NOTE: When calling other batch files from this login script,there are two important things to keep in mind.
REM - always be sure to use 'call' before the batch file name
REM - never use 'exit' in the batch file that you are calling
REM Failure to keep these things in mind will cause this login script to terminate after calling.
REM the other batch file.

REM Determine Subnet, do things based on SUBNET
REM ALL USERS section is where things go that need to happen for all users regardless of subnet.
REM

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

if %SUBNET% LEQ 60 goto Place1
if %SUBNET% GEQ 61 goto Place2

::I place this here and just remove END
:ALL_USERS
NET USE G: /DELETE
NET USE G: \\SERVER1\Shared
NET USE O: /DELETE
NET USE O: \\SERVER1\Forms
REM Use this section to perform functions that pertain to all users
goto :rest

@Ryan9577: did you write the batch file? If so, if you look at your first FOR loop, nothing happens. This is likely caused by the output in Win7 IPCONFIG is different from WinXP. You'll you to look at that. Also, the second FOR loop didn't do anything either, which is what eventually threw the error. I'd start with the first FOR loop though and once we get past that we'll look at the second.

For Each objAdapter in colAdapters
For Each strAddress in objAdapter.IPAddress
arrOctets = Split(strAddress, ".")
If arrOctets(0) <> "" Then
strSubnet = arrOctets(3)
x = 1
Exit For
End If
If x = 1 Then
Exit For
End If
Next
Next

I'm guessing the / switches either aren't supported but I'm not an uber guru on mapping drives with a VBScript ^_^

Yeah, they didn't work, he actually corrected in his 3pm post.

Ryan, interesting what you're doing here. Why the different mappings for different subnets? I assume the "general" mappings are for the shared areas? So if someone roams to the other subnet they can use those...

For Each objAdapter in colAdapters
For Each strAddress in objAdapter.IPAddress
arrOctets = Split(strAddress, ".")
If arrOctets(0) <> "" Then
strSubnet = arrOctets(3)
x = 1
Exit For
End If
If x = 1 Then
Exit For
End If
Next
Next

' Group based drive mappings

' Connect to the user account
Set objUser = GetObject("LDAP://" & objADSysInfo.UserName)
' Get all of the users groups
strGroups = Join(objUser.GetEx("memberOf"), ";")

I chose to remove the drives every time to make the connections active and to also remove any mapped drive that might conflict.

I chose rather to delete them one by one, rather then all at once in case I added a different share and didn't want it removed.

From a logic perpective it would make more sense to disconnect all mapped drives at login in a single command and then connect the ones the user should have access to.

This way your login script becomes the Master Of The Mapped Drives and if you want to add or remove mapped drives, you only have to edit a single script.

Also it would disconnect any unauthorised mappings that the user has either mapped themselves or any other reason a share might be mapped when you don't want it to be.

Not a bad script all in all.

I use a single vbscript across multiple offices that takes the first three characters of the computer name and uses that to decide where it is and what it should map in addition to group memberships.

As you hinted at with the printer idea, having a central script makes your administration easier. For example, I'm extending my script to write outlook signatures based on AD information at the moment.

The login script I'm using below is not working on windows 7. Not of my drives are mapped. Does any know what is the issue. Currently I'm the only one using Windows 7 so it's not an issue. But I need to get it fixed and also fixed in a way that it'll work for both XP and 7 as I imagine I'll be using a mixed environment for quite some time.

THANKS!

@echo off
cls

REM LOGIN.BAT
REM Default Login Script
REM
REM NOTE: When calling other batch files from this login script,there are two important things to keep in mind.
REM - always be sure to use 'call' before the batch file name
REM - never use 'exit' in the batch file that you are calling
REM Failure to keep these things in mind will cause this login script to terminate after calling.
REM the other batch file.

REM Determine Subnet, do things based on SUBNET
REM ALL USERS section is where things go that need to happen for all users regardless of subnet.
REM

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

if %SUBNET% LEQ 60 goto Place1
if %SUBNET% GEQ 61 goto Place2

::I place this here and just remove END
:ALL_USERS
NET USE G: /DELETE
NET USE G: \\SERVER1\Shared
NET USE O: /DELETE
NET USE O: \\SERVER1\Forms
REM Use this section to perform functions that pertain to all users
goto :rest