Why go through all the headache (not to mention the hit on the TCP/IP
stack[1]) of that if statement??

if "%OS%"=="Windows_NT" set NETSW=/persistent:no %NETSW%
    ^^^^^^^^^^^^^^^^^^

That does the same thing, and is more accurate than what you're doing.

--------------------------------------------------------------
Roger D. Seielstad - MTS MCSE MS-MVP
Sr. Systems Administrator
Inovis Inc.

[1] Using a UNC to check for the existance of a local file like you're doing
does that every time.


> -----Original Message-----
> From: Bruce Fyfe [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, June 17, 2003 5:11 PM
> To: NT 2000 Discussions
> Subject: RE: Windows Login Scripts
> 
> 
> Here is a logon script and associated VBS file that will do 
> what you need (I think):
> 
> -------logon.bat--------
> @ECHO on
> CLS
> ECHO ACMM Co. Network Information Systems
> ECHO This system is intended for employee use only.
> ECHO Please wait while your settings are initialized...
> 
> REM
> REM Check for existence of Windows NT
> REM
> 
> IF EXIST \\localhost\%systemroot%\SYSTEM32\CMD.EXE GOTO Meta 
> rem >NUL: 2>&1 IF EXIST C:\WTSRV\SYSTEM32\CMD.EXE GOTO Meta
> rem>NUL: 2>&1
> If exist c:\winnt\system32\cmd.exe goto meta
> rem >NUL: 2>&1
> 
> REM
> REM Check if the 9x client has wscript.exe
> REM
> 
> IF EXIST C:\WINDOWS\WSCRIPT.EXE GOTO Meta
> REM rem>NUL: 2>&1
> copy \\seant2ka\netlogon\Wscript.exe c:\windows
> REM rem >NUL: 2>&1
> 
> REM
> REM Delete all users drive mappings
> REM
> 
> :Meta
> 
> If exist k: net use k: /delete >NUL: 2>&1
> If exist l: net use l: /delete >NUL: 2>&1
> If exist m: net use m: /delete >NUL: 2>&1
> If exist n: net use n: /delete >NUL: 2>&1
> If exist o: net use o: /delete >NUL: 2>&1
> If exist p: net use p: /delete >NUL: 2>&1
> If exist q: net use q: /delete >NUL: 2>&1
> If exist r: net use r: /delete >NUL: 2>&1
> If exist s: net use s: /delete >NUL: 2>&1
> If exist t: net use t: /delete >NUL: 2>&1
> If exist x: net use x: /delete >NUL: 2>&1
> If exist y: net use y: /delete >NUL: 2>&1
> If exist z: net use z: /delete >NUL: 2>&1
> 
> REM logon.vbs is used to map drived based on group membership 
> wscript.exe \\server\netlogon\logon.vbs //nologo >NUL: 2>&1
> 
> :end
> ----------------end of logon.bat----------------
> 
> ----------------logon.vbs-----------------------
> 
> '=====================================================================
> '  FUNCTION TO MAP DRIVES BY GROUP MEMBERSHIP 
> '=====================================================================
> 
> Function MapDriveIfMember (ByVal Drive, ByVal Path, ByVal Group)
> 
> '
> '  Return Values:
> '    0 = Not Member of Group
> '    1 = Group Member and Drive Mapped
> '    2 = Drive not mapped due to error
> '
> 
> On Error Resume Next
> 
> Set WshShell = WScript.CreateObject("WScript.Shell")
> Set WshNetwork = WScript.CreateObject("WScript.Network")
> Set oGroup = GetObject("WinNT://" & WshNetwork.UserDomain & 
> "/" & Group)
> 
> MapDriveIfMember = 0
> 
> If oGroup.IsMember("WinNT://" & WshNetwork.UserDomain & "/" & 
> WshNetwork.UserName) Then
> 
>    Set oDrives = WshNetwork.EnumNetworkDrives
>    For i = 0 to oDrives.Count -1
>         if oDrives.Item(i) = Drive then 
> WshNetwork.RemoveNetworkDrive Drive, -1, -1
>    Next
>    WshNetwork.MapNetworkDrive Drive, Path
> 
>    MapDriveIfMember = 1
>           
> End If
> 
> If Not Err.Number = 0 Then MapDriveIfMember = 2 : 
> WshShell.LogEvent 4, "Map by Group Function - User: " & 
> WshNetwork.Username & " failed to Drive " & Drive & " to " & 
> Path : Err.Clear
> 
> End Function
> 
> 
> '=====================================================================
> '  FUNCTION TO MAP DRIVES BY USERNAME 
> '=====================================================================
> 
> Function MapDriveIfUser (ByVal Drive, ByVal Path, ByVal User)
> 
> '
> '  Return Values:
> '    0 = Not Member of Group
> '    1 = Group Member and Drive Mapped
> '    2 = Drive not mapped due to error
> '
> 
> On Error Resume Next
> 
> Set WshShell = WScript.CreateObject("WScript.Shell")
> Set WshNetwork = WScript.CreateObject("WScript.Network")
> 
> MapDriveIfUser = 0
> 
> If LCase(WshNetwork.UserName) = LCase(User) Then
> 
>    Set oDrives = WshNetwork.EnumNetworkDrives
>    For i = 0 to oDrives.Count -1
>         if oDrives.Item(i) = Drive then 
> WshNetwork.RemoveNetworkDrive Drive, -1, -1
>    Next
>    WshNetwork.MapNetworkDrive Drive, Path
> 
>    MapDriveIfUser = 1
>           
> End If
> 
> If Not Err.Number = 0 Then MapDriveIfMember = 2 : 
> WshShell.LogEvent 4, "Map by User Function - User: " & 
> WshNetwork.Username & " failed to Drive " & Drive & " to " & 
> Path : Err.Clear
> 
> End Function
> 
> 
> '=====================================================================
> '  LOGON SCRIPT REALLY STARTS BELOW THIS LINE 
> '=====================================================================
> 
> 
> Set WshShell = WScript.CreateObject("WScript.Shell")
> Set WshProEnv = WshShell.Environment("PROCESS")
> Set WshNetwork = WScript.CreateObject("WScript.Network")
> 
> '=====================================================================
> '  Sample Drive Letter Mappings by Group Name 
> '=====================================================================
> 
> 'rv = MapDriveIfMember ("X:", "\\servername\sharename", 
> "Group Name" & "Domain Admin") 'rv = MapDriveIfMember ("X:", 
"\\servername\sharename", "AC - Name")


-----------end of logon.vbs-------------------------------

-----Original Message-----
From: Chris Blatnik [mailto:[EMAIL PROTECTED]
Sent: Tuesday, June 17, 2003 11:52 AM
To: NT 2000 Discussions
Subject: Windows Login Scripts


Hi all 
Has any of you ever written a login script that contains an if statement? I
want my users to map drives base on group membership. If you have a sample
script or batch file please help.

Thanks
Cal

------
You are subscribed as [EMAIL PROTECTED]
Web Interface:
http://intm-dl.sparklist.com/cgi-bin/lyris.pl?enter=nt2000&text_mode=&lang=e
nglish
To unsubscribe send a blank email to %%email.unsub%%

------
You are subscribed as [EMAIL PROTECTED]
Web Interface:
http://intm-dl.sparklist.com/cgi-bin/lyris.pl?enter=nt2000&text_mode=&lang=e
nglish
To unsubscribe send a blank email to %%email.unsub%%

------
You are subscribed as [EMAIL PROTECTED]
Web Interface: 
http://intm-dl.sparklist.com/cgi-bin/lyris.pl?enter=nt2000&text_mode=&lang=english
To unsubscribe send a blank email to [EMAIL PROTECTED]

Reply via email to