LOGIN SCRIPT



Here is my script:

The new script!

' VBScript logon script program.
'
'
----------------------------------------------------------------------
' Copyright (c) 2006 Exploitatie Maatschappij Bieze bv
' Version 1.0 - Maart 2006


Option Explicit

Dim objNetwork, objSysInfo, strUserDN
Dim objGroupList, objUser, objFSO
Dim strComputerDN, objComputer

Dim WshShell, SHell
Dim oFS, oWS
Dim strHomeDrive

Set objNetwork = CreateObject("Wscript.Network")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objSysInfo = CreateObject("ADSystemInfo")
strUserDN = objSysInfo.userName
strComputerDN = objSysInfo.computerName


Set WshShell = WScript.CreateObject("WScript.Shell")
Set Shell = CreateObject("Shell.Application")
Set oWS = WScript.CreateObject("WScript.Shell")
Set oFS = WScript.CreateObject("Scripting.FileSystemObject")

' Bind to the user and computer objects with the LDAP provider.
Set objUser = GetObject("LDAP://"; & strUserDN)
Set objComputer = GetObject("LDAP://"; & strComputerDN)






'NEPTUNUS

' Map a network drive if the user is a member of the group.

If IsMember(objUser, "dlNpPS-R") Then
objNetwork.MapNetworkDrive "F:", "\\en-dc01\Persoonlijk Neptunus\" &
objNetwork.UserName ,True
End If

If IsMember(objUser, "dlNpGZ-R") Then
objNetwork.MapNetworkDrive "G:", "\\en-dc01\Gezamenlijk Neptunus" ,True
End If

If IsMember(objUser, "dlNpAPPL-R") Then
objNetwork.MapNetworkDrive "H:", "\\en-dc01\Appl Neptunus" ,True
End If


If IsMember(objUser, "dlNpINSTAL-R") Then
objNetwork.MapNetworkDrive "I:", "\\en-dc01\Installatie Neptunus" ,True
End If

'Outlook
Const sOrgFile = "c:\documents and settings\%username%\Outlook.txt"

If IsFile(sOrgFile) Then


'Nothing
Else
WshShell.Run "OUTLOOK.EXE /importprf
\\biezegroep.net\sysvol\BIEZEGROEP.NET\scripts\Neptunus\Inlog\NPoutlook.prf"
,True
On Error Resume Next

End If






' Clean up.
Set objNetwork = Nothing
Set objFSO = Nothing
Set objSysInfo = Nothing
Set objGroupList = Nothing
Set objUser = Nothing
Set objComputer = Nothing

Set oWS = Nothing
Set oFS = Nothing

Function IsMember(objADObject, strGroup)
' Function to test for group membership.
' objGroupList is a dictionary object with global scope.

If IsEmpty(objGroupList) Then
Set objGroupList = CreateObject("Scripting.Dictionary")
End If
If Not objGroupList.Exists(objADObject.sAMAccountName & "\") Then
Call LoadGroups(objADObject, objADObject)
objGroupList(objADObject.sAMAccountName & "\") = True
End If
IsMember = objGroupList.Exists(objADObject.sAMAccountName & "\" _
& strGroup)
End Function

Function IsFile(fName)
On Error Resume Next
If oFS.FileExists(fName) Then IsFile = True Else IsFile = False
On Error Goto 0
End Function

Sub LoadGroups(objPriObject, objADSubObject)
' Recursive subroutine to populate dictionary object objGroupList.

Dim colstrGroups, objGroup, j

objGroupList.CompareMode = vbTextCompare
colstrGroups = objADSubObject.memberOf
If IsEmpty(colstrGroups) Then
Exit Sub
End If
If TypeName(colstrGroups) = "String" Then
Set objGroup = GetObject("LDAP://"; & colstrGroups)
If Not objGroupList.Exists(objPriObject.sAMAccountName & "\" _
& objGroup.sAMAccountName) Then
objGroupList(objPriObject.sAMAccountName & "\" _
& objGroup.sAMAccountName) = True
Call LoadGroups(objPriObject, objGroup)
End If
Set objGroup = Nothing
Exit Sub
End If
For j = 0 To UBound(colstrGroups)
Set objGroup = GetObject("LDAP://"; & colstrGroups(j))
If Not objGroupList.Exists(objPriObject.sAMAccountName & "\" _
& objGroup.sAMAccountName) Then
objGroupList(objPriObject.sAMAccountName & "\" _
& objGroup.sAMAccountName) = True
Call LoadGroups(objPriObject, objGroup)
End If
Next
Set objGroup = Nothing
End Sub





AND my new problem:

'Outlook
Const sOrgFile = "c:\documents and settings\%username%\Outlook.txt"

If IsFile(sOrgFile) Then


'Nothing
Else
WshShell.Run "OUTLOOK.EXE /importprf
\\biezegroep.net\sysvol\BIEZEGROEP.NET\scripts\Neptunus\Inlog\NPoutlook.prf"
,True
On Error Resume Next

End If


What i want is:

When a user loged in this script look on his documents and settings
folder if the "outlook.txt" file exist.

If this file exist then there is nothing to do...
if this file NOT exist then must the outlook profile be installed...
and there must be created a "outlook.txt" in the documents and settings
file %username%


Can you help?


Thanks

.



Relevant Pages

  • Login Script to Install Printers Based on Computer Group
    ... computer based on what group the computer account was in. ... originally had the printers installed via a login script when the user ... Dim objNetwork, objSysInfo, strUserDN ... Call LoadGroups(objPriObject, objGroup) ...
    (microsoft.public.win2000.active_directory)
  • Re: Login Script Causing Software to Install
    ... of the script as the logon script. ... You might have to wait a moment on each msgbox to see if the install starts. ... > Dim objNetwork, objSysInfo, strUserDN ... > Call LoadGroups(objPriObject, objGroup) ...
    (microsoft.public.scripting.wsh)
  • Re: mapped network drive does not show name
    ... added the description back (after the logon script had mapped the ... Dim objNetwork, objSysInfo, strUserDN, objUser, strUser ... For Each objGroup In objUser.Groups ...
    (microsoft.public.scripting.wsh)
  • Map network drive to user
    ... Dim objNetwork, objSysInfo, strUserDN ... Set objFSO = CreateObject ... Set objSysInfo = CreateObject ... Call LoadGroups(objPriObject, objGroup) ...
    (microsoft.public.windows.server.scripting)
  • RE: export user accounts from NT 4.0 domain
    ... ATTENTION THE SCRIPT MUST BE RUNNED FROM A COMPUTER WHERE EXCEL IS ... from the information in a Microsoft Excel spreadsheet. ... Dim strLast, strFirst, strMiddle, strPW, intRow, intCol ... On Error GoTo 0 ...
    (microsoft.public.windows.server.scripting)