login scripts using WSH in vbscripts 
Author Message
 login scripts using WSH in vbscripts

hi guys, Im a desktop support at my company and i dont know much about WSH
and havent done any programming whatsoever..  Anyway, I've been assigned to
do a special task  and  create a login script that will work on a windows
2000 domain based active directory environment. with Winxp pro as the
clients.

What we need is to create a logon script that will have all my users and map
them to the appropriate shares according to thier OU's or depts, that they
have an antivirus installed on thier pc's and any sample login scripts that
may help me would be gladly appreciated.

thx

Luke Beckham
MCP



Mon, 11 Apr 2005 11:47:51 GMT  
 login scripts using WSH in vbscripts

Quote:

>hi guys, Im a desktop support at my company and i dont
know much about WSH
>and havent done any programming whatsoever..  Anyway,

I've been assigned to
Quote:
>do a special task  and  create a login script that will
work on a windows
>2000 domain based active directory environment. with
Winxp pro as the
>clients.

>What we need is to create a logon script that will have

all my users and map
Quote:
>them to the appropriate shares according to thier OU's or
depts, that they
>have an antivirus installed on thier pc's and any sample
login scripts that
>may help me would be gladly appreciated.

>thx

>Luke Beckham
>MCP

Hi,

Since all your clients are XP, you can use ADSystemInfo.
The IsMember function below handles "nested" groups, and
won't crash if they are circular. If you need OU
information, you can parse sUserAdsPath. If you put
computers in groups, you can test computer group
membership to map printers in a similar way.

Option Explicit
Dim oNet, oSysInfo, sUserAdsPath
Dim oGroupList, oUser

Set oNet = CreateObject("Wscript.Network")
Set oSysInfo = CreateObject("ADSystemInfo")
sUserAdsPath = oSysInfo.UserName

Set oUser = GetObject("LDAP://" & sUserAdsPath)

If IsMember("Sales") Then
  oNet.MapNetworkDrive "M:", "\\MyServer\MyShare"
End If

Function IsMember(sGroup)
' Function to test for group membership.
  If IsEmpty(oGroupList) Then
    Set oGroupList = CreateObject("Scripting.Dictionary")
    Call LoadGroups(oUser)
  End If
  IsMember = oGroupList.Exists(sGroup)
End Function

Sub LoadGroups(oADObject)
' Recursive subroutine to populate dictionary object.
  Dim sGroups, oGroup, j
  oGroupList.CompareMode = vbTextCompare
  sGroups = oADObject.MemberOf
  If IsEmpty(sGroups) Then
    Exit Sub
  End If
  If TypeName(sGroups) = "String" Then
    Set oGroup = GetObject("LDAP://" & sGroups)
    If Not oGroupList.Exists(oGroup.sAMAccountName) Then
      oGroupList(oGroup.sAMAccountName) = True
      Call LoadGroups(oGroup)
    End If
    Set oGroup = Nothing
    Exit Sub
  End If
  For j = 0 To UBound(sGroups)
    Set oGroup = GetObject("LDAP://" & sGroups(j))
    If Not oGroupList.Exists(oGroup.sAMAccountName) Then
      oGroupList(oGroup.sAMAccountName) = True
      Call LoadGroups(oGroup)
    End If
  Next
  Set oGroup = Nothing
End Sub

Richard



Mon, 11 Apr 2005 23:55:15 GMT  
 login scripts using WSH in vbscripts
. I will give it a try and let you the outcome.

thanks richard


Quote:

> >hi guys, Im a desktop support at my company and i dont
> know much about WSH
> >and havent done any programming whatsoever..  Anyway,
> I've been assigned to
> >do a special task  and  create a login script that will
> work on a windows
> >2000 domain based active directory environment. with
> Winxp pro as the
> >clients.

> >What we need is to create a logon script that will have
> all my users and map
> >them to the appropriate shares according to thier OU's or
> depts, that they
> >have an antivirus installed on thier pc's and any sample
> login scripts that
> >may help me would be gladly appreciated.

> >thx

> >Luke Beckham
> >MCP

> Hi,

> Since all your clients are XP, you can use ADSystemInfo.
> The IsMember function below handles "nested" groups, and
> won't crash if they are circular. If you need OU
> information, you can parse sUserAdsPath. If you put
> computers in groups, you can test computer group
> membership to map printers in a similar way.

> Option Explicit
> Dim oNet, oSysInfo, sUserAdsPath
> Dim oGroupList, oUser

> Set oNet = CreateObject("Wscript.Network")
> Set oSysInfo = CreateObject("ADSystemInfo")
> sUserAdsPath = oSysInfo.UserName

> Set oUser = GetObject("LDAP://" & sUserAdsPath)

> If IsMember("Sales") Then
>   oNet.MapNetworkDrive "M:", "\\MyServer\MyShare"
> End If

> Function IsMember(sGroup)
> ' Function to test for group membership.
>   If IsEmpty(oGroupList) Then
>     Set oGroupList = CreateObject("Scripting.Dictionary")
>     Call LoadGroups(oUser)
>   End If
>   IsMember = oGroupList.Exists(sGroup)
> End Function

> Sub LoadGroups(oADObject)
> ' Recursive subroutine to populate dictionary object.
>   Dim sGroups, oGroup, j
>   oGroupList.CompareMode = vbTextCompare
>   sGroups = oADObject.MemberOf
>   If IsEmpty(sGroups) Then
>     Exit Sub
>   End If
>   If TypeName(sGroups) = "String" Then
>     Set oGroup = GetObject("LDAP://" & sGroups)
>     If Not oGroupList.Exists(oGroup.sAMAccountName) Then
>       oGroupList(oGroup.sAMAccountName) = True
>       Call LoadGroups(oGroup)
>     End If
>     Set oGroup = Nothing
>     Exit Sub
>   End If
>   For j = 0 To UBound(sGroups)
>     Set oGroup = GetObject("LDAP://" & sGroups(j))
>     If Not oGroupList.Exists(oGroup.sAMAccountName) Then
>       oGroupList(oGroup.sAMAccountName) = True
>       Call LoadGroups(oGroup)
>     End If
>   Next
>   Set oGroup = Nothing
> End Sub

> Richard



Tue, 12 Apr 2005 07:41:58 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Using a WSH Script as a Login Script

2. Using WSH login scripts to assign temp local system admin previllege

3. using wsh as login script language

4. Using VBScript in NT Login Script

5. Executing a WSH script as a login script

6. Auto-Login using WSH?

7. Nt Domain Logon Script using VBScript/WSH

8. NT Logon Script using WSH / VBScript

9. vbscript login scripts - starting a script from the Windows 95 command prompt

10. Converting a login.bat to login.wsh

11. Custom WSH login *before* Client32 login?

12. Help, login problem WSH vbscript

 

 
Powered by phpBB® Forum Software