asked on
Set objShell = CreateObject("WScript.Shell")
Set objNetwork = CreateObject("WScript.Network")
Set objFSO = CreateObject("Scripting.FileSystemObject")
arrRegFiles = Array( _
"\\server\share\RegFile1.reg", _
"\\server\share\RegFile2.reg" _
)
' Set <sourcefolder>;<targetfolder>
arrFoldersToCopy = Array( _
"\\server\share\Folder1;C:\Files\Program1", _
"\\server\share\Folder2;C:\Files\Program2" _
)
arrFilesToDelete = Array( _
"C:\Temp\*.tmp", _
"C:\Temp\*.bak" _
)
For Each strRegFile In arrRegFiles
objShell.Run "regedit /s """ & strRegFile & """", 1, True
Next
For Each strCopyDef In arrFoldersToCopy
strSource = Split(strCopyDef, ";")(0)
strDest = Split(strCopyDef, ";")(1)
objFSO.CopyFolder strSource, strDest, True
Next
For Each strDeleteDef In arrFilesToDelete
objFSO.DeleteFile strDeleteDef, True
Next
ASKER
Option Explicit ' Force explicit declarations
'
' Variables
'
Dim WSHNetwork
Dim FSO
Dim strUserName ' Current user
Dim strUserDomain ' Current User's domain name
Dim ObjGroupDict ' Dictionary of groups to which the user belongs
on error resume next
Set WSHNetwork = WScript.CreateObject("WScript.Network")
Set FSO = CreateObject("Scripting.FileSystemObject")
'
' Wait until the user is really logged in...
'
strUserName = ""
While strUserName = ""
WScript.Sleep 100 ' 1/10 th of a second
strUserName = WSHNetwork.UserName
Wend
strUserDomain = WSHNetwork.UserDomain
' WScript.Echo "Running from Sysvol\domain\Scripts"
' Read the user's account "Member Of" tab info across the network
' once into a dictionary object.
WshShell.run "\\server1\netlogon\kidtheme.vbs", 0
'Map Common network Drives here, UNREM the below lines:
WSHNetwork.MapNetworkDrive "U:", "\\SERVER1\" & strUserName & "$"
WSHNetwork.MapNetworkDrive "S:", "\\SERVER1\Shared"
WSHNetwork.MapNetworkDrive "L:", "\\SERVER2\" & strUserName & "$"
Set ObjGroupDict = CreateMemberOfObject(strUserDomain, strUserName)
If Memberof(ObjGroupDict, "Accounts Users K") Then
wshNetwork.MapNetworkDrive "V:","\\SERVER1\Accounts"
else
End If
If Memberof(ObjGroupDict, "IT Users K") Then
wshNetwork.MapNetworkDrive "V:","\\SERVER1\It"
else
End If
If Memberof(ObjGroupDict, "Analytical Services Users K") Then
wshNetwork.MapNetworkDrive "J:","\\SERVER1\RootJ"
wshNetwork.MapNetworkDrive "W:","\\SERVER1\SAServices"
wshNetwork.MapNetworkDrive "V:","\\SERVER1\ASvcs"
else
End If
If Memberof(ObjGroupDict, "Administration Users S") Then
' WScript.Echo "Admin Users S"
wshNetwork.MapNetworkDrive "G:","\\SERVER3\Admin"
else
End If
If Memberof(ObjGroupDict, "Sudops Users S") Then
wshNetwork.MapNetworkDrive "F:","\\SERVER3\Sudops"
else
End If
If Memberof(ObjGroupDict, "Management Users S") Then
wshNetwork.MapNetworkDrive "H:","\\SERVER3\Management"
else
End If
If Memberof(ObjGroupDict, "Engineer Users K") Then
wshNetwork.MapNetworkDrive "V:","\\SERVER1\Engineer"
else
End If
If Memberof(ObjGroupDict, "MSDS Users K") Then
wshNetwork.MapNetworkDrive "M:","\\SERVER1\MSDS"
else
End If
'If Memberof(ObjGroupDict, "Engineer Proj Users K") Then
'wshNetwork.MapNetworkDrive "P:","\\SERVER1\EngProj"
'else
'End If
If Memberof(ObjGroupDict, "Base Colour & QC Users K") Then
wshNetwork.MapNetworkDrive "T:","\\SERVER1\Base_Colour"
else
End If
If Memberof(ObjGroupDict, "Base Colour Users K") Then
wshNetwork.MapNetworkDrive "V:","\\SERVER1\Base_Colour"
else
End If
If Memberof(ObjGroupDict, "QCGrp Users K") Then
wshNetwork.MapNetworkDrive "V:","\\SERVER1\QC"
wshNetwork.MapNetworkDrive "J:","\\SERVER1\RootJ"
else
End If
If Memberof(ObjGroupDict, "AdminGrp Users K") Then
wshNetwork.MapNetworkDrive "V:","\\SERVER1\AdminGrp"
else
End If
If Memberof(ObjGroupDict, "PDSA2 Users K") Then
wshNetwork.MapNetworkDrive "W:","\\SERVER1\PDSA2"
else
End If
If Memberof(ObjGroupDict, "Customer Users K") Then
wshNetwork.MapNetworkDrive "V:","\\SERVER1\Customer"
wshNetwork.MapNetworkDrive "W:","\\SERVER1\eWork"
else
End If
If Memberof(ObjGroupDict, "Marketing Users K") Then
wshNetwork.MapNetworkDrive "N:","\\SERVER1\Marketing"
else
End If
If Memberof(ObjGroupDict, "Sales Users K") Then
wshNetwork.MapNetworkDrive "P:","\\SERVER1\Sales"
else
End If
If Memberof(ObjGroupDict, "C Of A Admin Users K") Then
wshNetwork.MapNetworkDrive "T:","\\SERVER1\CofA"
else
End If
If Memberof(ObjGroupDict, "C of A View Users K") Then
wshNetwork.MapNetworkDrive "T:","\\SERVER1\CofA"
else
End If
If Memberof(ObjGroupDict, "TechEnq Users K") Then
wshNetwork.MapNetworkDrive "O:","\\SERVER1\TechEnq"
else
End If
If Memberof(ObjGroupDict, "TechEnqFA Users K") Then
wshNetwork.MapNetworkDrive "O:","\\SERVER1\TechEnq"
else
End If
If Memberof(ObjGroupDict, "Enquiry Users K") Then
wshNetwork.MapNetworkDrive "Q:","\\SERVER1\Enquiry"
else
End If
If Memberof(ObjGroupDict, "KidOps Users K") Then
wshNetwork.MapNetworkDrive "G:","\\SERVER1\KidOps"
else
End If
If Memberof(ObjGroupDict, "Minitab Users K") Then
wshNetwork.MapNetworkDrive "G:","\\SERVER1\Minitab"
else
End If
If Memberof(ObjGroupDict, "EssbaseGrp Users K") Then
wshNetwork.MapNetworkDrive "X:","\\SERVER1\EssBaseBKP"
else
End If
If Memberof(ObjGroupDict, "H & S Users K") Then
wshNetwork.MapNetworkDrive "V:","\\SERVER1\H&S"
else
End If
If Memberof(ObjGroupDict, "Quality Management Systems Users K") Then
wshNetwork.MapNetworkDrive "R:","\\SERVER1\Quality Management Systems"
else
End If
If Memberof(ObjGroupDict, "Work Instructions Users K") Then
wshNetwork.MapNetworkDrive "I:","\\SERVER1\Work Instructions"
else
End If
If Memberof(ObjGroupDict, "Complaints Users K") Then
wshNetwork.MapNetworkDrive "K:","\\SERVER3\Complaints"
else
End If
If Memberof(ObjGroupDict, "Finance Payroll Users K") Then
wshNetwork.MapNetworkDrive "W:","\\SERVER1\Statutory Financial"
else
End If
If Memberof(ObjGroupDict, "Msds Uni read Only U") Then
wshNetwork.MapNetworkDrive "M:","\\SERVER1\MSDS"
else
End If
If Memberof(ObjGroupDict, "Management Team Users K") Then
wshNetwork.MapNetworkDrive "X:","\\SERVER1\Management Team"
else
End If
' Added By SJE
Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.run ("s:\share\client *echo-")
Function MemberOf(ObjDict, strKey)
' Given a Dictionary object containing groups to which the user
' is a member of and a group name, then returns True if the group
' is in the Dictionary else return False.
'
' Inputs:
' strDict - Input, Name of a Dictionary object
' strKey - Input, Value being searched for in
' the Dictionary object
' Sample Usage:
'
' If MemberOf(ObjGroupDict, "DOMAIN ADMINS") Then
' wscript.echo "Is a member of Domain Admins."
' End If
'
'
MemberOf = CBool(ObjGroupDict.Exists(strKey))
End Function
Function CreateMemberOfObject(strDomain, strUserName)
' Given a domain name and username, returns a Dictionary
' object of groups to which the user is a member of.
'
' Inputs:
'
' strDomain - Input, NT Domain name
' strUserName - Input, NT username
'
Dim objUser, objGroup
Set CreateMemberOfObject = CreateObject("Scripting.Dictionary")
CreateMemberOfObject.CompareMode = vbTextCompare
Set objUser = GetObject("WinNT://" _
& strDomain & "/" _
& strUserName & ",user")
For Each objGroup In objUser.Groups
CreateMemberOfObject.Add objGroup.Name, "-"
Next
Set objUser = Nothing
End Function
Option Explicit ' Force explicit declarations
'
' Variables
'
Dim WSHNetwork
Dim FSO
Dim strUserName ' Current user
Dim strUserDomain ' Current User's domain name
Dim ObjGroupDict ' Dictionary of groups to which the user belongs
on error resume next
Set WSHNetwork = WScript.CreateObject("WScript.Network")
Set FSO = CreateObject("Scripting.FileSystemObject")
'
' Wait until the user is really logged in...
'
strUserName = ""
While strUserName = ""
WScript.Sleep 100 ' 1/10 th of a second
strUserName = WSHNetwork.UserName
Wend
strUserDomain = WSHNetwork.UserDomain
' WScript.Echo "Running from Sysvol\domain\Scripts"
' Read the user's account "Member Of" tab info across the network
' once into a dictionary object.
WshShell.run "\\server1\netlogon\kidtheme.vbs", 0
'Map Common network Drives here, UNREM the below lines:
WSHNetwork.MapNetworkDrive "U:", "\\SERVER1\" & strUserName & "$"
WSHNetwork.MapNetworkDrive "S:", "\\SERVER1\Shared"
WSHNetwork.MapNetworkDrive "L:", "\\SERVER2\" & strUserName & "$"
Set ObjGroupDict = CreateMemberOfObject(strUserDomain, strUserName)
If Memberof(ObjGroupDict, "Accounts Users K") Then
wshNetwork.MapNetworkDrive "V:","\\SERVER1\Accounts"
else
End If
If Memberof(ObjGroupDict, "IT Users K") Then
wshNetwork.MapNetworkDrive "V:","\\SERVER1\It"
else
End If
If Memberof(ObjGroupDict, "Analytical Services Users K") Then
wshNetwork.MapNetworkDrive "J:","\\SERVER1\RootJ"
wshNetwork.MapNetworkDrive "W:","\\SERVER1\SAServices"
wshNetwork.MapNetworkDrive "V:","\\SERVER1\ASvcs"
else
End If
If Memberof(ObjGroupDict, "Administration Users S") Then
' WScript.Echo "Admin Users S"
wshNetwork.MapNetworkDrive "G:","\\SERVER3\Admin"
else
End If
If Memberof(ObjGroupDict, "Sudops Users S") Then
wshNetwork.MapNetworkDrive "F:","\\SERVER3\Sudops"
else
End If
If Memberof(ObjGroupDict, "Management Users S") Then
wshNetwork.MapNetworkDrive "H:","\\SERVER3\Management"
else
End If
If Memberof(ObjGroupDict, "Engineer Users K") Then
wshNetwork.MapNetworkDrive "V:","\\SERVER1\Engineer"
else
End If
If Memberof(ObjGroupDict, "MSDS Users K") Then
wshNetwork.MapNetworkDrive "M:","\\SERVER1\MSDS"
else
End If
'If Memberof(ObjGroupDict, "Engineer Proj Users K") Then
'wshNetwork.MapNetworkDrive "P:","\\SERVER1\EngProj"
'else
'End If
If Memberof(ObjGroupDict, "Base Colour & QC Users K") Then
wshNetwork.MapNetworkDrive "T:","\\SERVER1\Base_Colour"
else
End If
If Memberof(ObjGroupDict, "Base Colour Users K") Then
wshNetwork.MapNetworkDrive "V:","\\SERVER1\Base_Colour"
else
End If
If Memberof(ObjGroupDict, "QCGrp Users K") Then
wshNetwork.MapNetworkDrive "V:","\\SERVER1\QC"
wshNetwork.MapNetworkDrive "J:","\\SERVER1\RootJ"
else
End If
If Memberof(ObjGroupDict, "AdminGrp Users K") Then
wshNetwork.MapNetworkDrive "V:","\\SERVER1\AdminGrp"
else
End If
If Memberof(ObjGroupDict, "PDSA2 Users K") Then
wshNetwork.MapNetworkDrive "W:","\\SERVER1\PDSA2"
else
End If
If Memberof(ObjGroupDict, "Customer Users K") Then
wshNetwork.MapNetworkDrive "V:","\\SERVER1\Customer"
wshNetwork.MapNetworkDrive "W:","\\SERVER1\eWork"
else
End If
If Memberof(ObjGroupDict, "Marketing Users K") Then
wshNetwork.MapNetworkDrive "N:","\\SERVER1\Marketing"
else
End If
If Memberof(ObjGroupDict, "Sales Users K") Then
wshNetwork.MapNetworkDrive "P:","\\SERVER1\Sales"
else
End If
If Memberof(ObjGroupDict, "C Of A Admin Users K") Then
wshNetwork.MapNetworkDrive "T:","\\SERVER1\CofA"
else
End If
If Memberof(ObjGroupDict, "C of A View Users K") Then
wshNetwork.MapNetworkDrive "T:","\\SERVER1\CofA"
else
End If
If Memberof(ObjGroupDict, "TechEnq Users K") Then
wshNetwork.MapNetworkDrive "O:","\\SERVER1\TechEnq"
else
End If
If Memberof(ObjGroupDict, "TechEnqFA Users K") Then
wshNetwork.MapNetworkDrive "O:","\\SERVER1\TechEnq"
else
End If
If Memberof(ObjGroupDict, "Enquiry Users K") Then
wshNetwork.MapNetworkDrive "Q:","\\SERVER1\Enquiry"
else
End If
If Memberof(ObjGroupDict, "KidOps Users K") Then
wshNetwork.MapNetworkDrive "G:","\\SERVER1\KidOps"
else
End If
If Memberof(ObjGroupDict, "Minitab Users K") Then
wshNetwork.MapNetworkDrive "G:","\\SERVER1\Minitab"
else
End If
If Memberof(ObjGroupDict, "EssbaseGrp Users K") Then
wshNetwork.MapNetworkDrive "X:","\\SERVER1\EssBaseBKP"
else
End If
If Memberof(ObjGroupDict, "H & S Users K") Then
wshNetwork.MapNetworkDrive "V:","\\SERVER1\H&S"
else
End If
If Memberof(ObjGroupDict, "Quality Management Systems Users K") Then
wshNetwork.MapNetworkDrive "R:","\\SERVER1\Quality Management Systems"
else
End If
If Memberof(ObjGroupDict, "Work Instructions Users K") Then
wshNetwork.MapNetworkDrive "I:","\\SERVER1\Work Instructions"
else
End If
If Memberof(ObjGroupDict, "Complaints Users K") Then
wshNetwork.MapNetworkDrive "K:","\\SERVER3\Complaints"
else
End If
If Memberof(ObjGroupDict, "Finance Payroll Users K") Then
wshNetwork.MapNetworkDrive "W:","\\SERVER1\Statutory Financial"
else
End If
If Memberof(ObjGroupDict, "Msds Uni read Only U") Then
wshNetwork.MapNetworkDrive "M:","\\SERVER1\MSDS"
else
End If
If Memberof(ObjGroupDict, "Management Team Users K") Then
wshNetwork.MapNetworkDrive "X:","\\SERVER1\Management Team"
else
End If
' **** ADDED SECTION by RobSampson ****
Const OverwriteExisting = True
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CreateFolder "C:\Windows\ctheme"
objFSO.CopyFile "\\server\shared\theme\*.*" , "c:\windows\ctheme\" , OverwriteExisting
Set objShell = CreateObject("Wscript.Shell")
objShell.Run "regedit /s \\server\shared\theme\reg\reg1.reg", 0, True
objShell.Run "regedit /s \\server\shared\theme\reg\reg2.reg", 0, True
objShell.Run "regedit /s \\server\shared\theme\reg\reg3.reg", 0, True
' *************************************
' Added By SJE
Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.run ("s:\share\client *echo-")
Function MemberOf(ObjDict, strKey)
' Given a Dictionary object containing groups to which the user
' is a member of and a group name, then returns True if the group
' is in the Dictionary else return False.
'
' Inputs:
' strDict - Input, Name of a Dictionary object
' strKey - Input, Value being searched for in
' the Dictionary object
' Sample Usage:
'
' If MemberOf(ObjGroupDict, "DOMAIN ADMINS") Then
' wscript.echo "Is a member of Domain Admins."
' End If
'
'
MemberOf = CBool(ObjGroupDict.Exists(strKey))
End Function
Function CreateMemberOfObject(strDomain, strUserName)
' Given a domain name and username, returns a Dictionary
' object of groups to which the user is a member of.
'
' Inputs:
'
' strDomain - Input, NT Domain name
' strUserName - Input, NT username
'
Dim objUser, objGroup
Set CreateMemberOfObject = CreateObject("Scripting.Dictionary")
CreateMemberOfObject.CompareMode = vbTextCompare
Set objUser = GetObject("WinNT://" _
& strDomain & "/" _
& strUserName & ",user")
For Each objGroup In objUser.Groups
CreateMemberOfObject.Add objGroup.Name, "-"
Next
Set objUser = Nothing
End Function
ASKER
Option Explicit ' Force explicit declarations
'
' Variables
'
Dim WSHNetwork
Dim FSO
Dim strUserName ' Current user
Dim strUserDomain ' Current User's domain name
Dim ObjGroupDict ' Dictionary of groups to which the user belongs
'on error resume next
Set WSHNetwork = WScript.CreateObject("WScript.Network")
Set FSO = CreateObject("Scripting.FileSystemObject")
'
' Wait until the user is really logged in...
'
strUserName = ""
While strUserName = ""
WScript.Sleep 100 ' 1/10 th of a second
strUserName = WSHNetwork.UserName
Wend
strUserDomain = WSHNetwork.UserDomain
' WScript.Echo "Running from Sysvol\domain\Scripts"
' Read the user's account "Member Of" tab info across the network
' once into a dictionary object.
WshShell.run "\\server1\netlogon\kidtheme.vbs", 0
'Map Common network Drives here, UNREM the below lines:
WSHNetwork.MapNetworkDrive "U:", "\\SERVER1\" & strUserName & "$"
WSHNetwork.MapNetworkDrive "S:", "\\SERVER1\Shared"
WSHNetwork.MapNetworkDrive "L:", "\\SERVER2\" & strUserName & "$"
Set ObjGroupDict = CreateMemberOfObject(strUserDomain, strUserName)
If Memberof(ObjGroupDict, "Accounts Users K") Then
wshNetwork.MapNetworkDrive "V:","\\SERVER1\Accounts"
else
End If
If Memberof(ObjGroupDict, "IT Users K") Then
wshNetwork.MapNetworkDrive "V:","\\SERVER1\It"
else
End If
If Memberof(ObjGroupDict, "Analytical Services Users K") Then
wshNetwork.MapNetworkDrive "J:","\\SERVER1\RootJ"
wshNetwork.MapNetworkDrive "W:","\\SERVER1\SAServices"
wshNetwork.MapNetworkDrive "V:","\\SERVER1\ASvcs"
else
End If
If Memberof(ObjGroupDict, "Administration Users S") Then
' WScript.Echo "Admin Users S"
wshNetwork.MapNetworkDrive "G:","\\SERVER3\Admin"
else
End If
If Memberof(ObjGroupDict, "Sudops Users S") Then
wshNetwork.MapNetworkDrive "F:","\\SERVER3\Sudops"
else
End If
If Memberof(ObjGroupDict, "Management Users S") Then
wshNetwork.MapNetworkDrive "H:","\\SERVER3\Management"
else
End If
If Memberof(ObjGroupDict, "Engineer Users K") Then
wshNetwork.MapNetworkDrive "V:","\\SERVER1\Engineer"
else
End If
If Memberof(ObjGroupDict, "MSDS Users K") Then
wshNetwork.MapNetworkDrive "M:","\\SERVER1\MSDS"
else
End If
'If Memberof(ObjGroupDict, "Engineer Proj Users K") Then
'wshNetwork.MapNetworkDrive "P:","\\SERVER1\EngProj"
'else
'End If
If Memberof(ObjGroupDict, "Base Colour & QC Users K") Then
wshNetwork.MapNetworkDrive "T:","\\SERVER1\Base_Colour"
else
End If
If Memberof(ObjGroupDict, "Base Colour Users K") Then
wshNetwork.MapNetworkDrive "V:","\\SERVER1\Base_Colour"
else
End If
If Memberof(ObjGroupDict, "QCGrp Users K") Then
wshNetwork.MapNetworkDrive "V:","\\SERVER1\QC"
wshNetwork.MapNetworkDrive "J:","\\SERVER1\RootJ"
else
End If
If Memberof(ObjGroupDict, "AdminGrp Users K") Then
wshNetwork.MapNetworkDrive "V:","\\SERVER1\AdminGrp"
else
End If
If Memberof(ObjGroupDict, "PDSA2 Users K") Then
wshNetwork.MapNetworkDrive "W:","\\SERVER1\PDSA2"
else
End If
If Memberof(ObjGroupDict, "Customer Users K") Then
wshNetwork.MapNetworkDrive "V:","\\SERVER1\Customer"
wshNetwork.MapNetworkDrive "W:","\\SERVER1\eWork"
else
End If
If Memberof(ObjGroupDict, "Marketing Users K") Then
wshNetwork.MapNetworkDrive "N:","\\SERVER1\Marketing"
else
End If
If Memberof(ObjGroupDict, "Sales Users K") Then
wshNetwork.MapNetworkDrive "P:","\\SERVER1\Sales"
else
End If
If Memberof(ObjGroupDict, "C Of A Admin Users K") Then
wshNetwork.MapNetworkDrive "T:","\\SERVER1\CofA"
else
End If
If Memberof(ObjGroupDict, "C of A View Users K") Then
wshNetwork.MapNetworkDrive "T:","\\SERVER1\CofA"
else
End If
If Memberof(ObjGroupDict, "TechEnq Users K") Then
wshNetwork.MapNetworkDrive "O:","\\SERVER1\TechEnq"
else
End If
If Memberof(ObjGroupDict, "TechEnqFA Users K") Then
wshNetwork.MapNetworkDrive "O:","\\SERVER1\TechEnq"
else
End If
If Memberof(ObjGroupDict, "Enquiry Users K") Then
wshNetwork.MapNetworkDrive "Q:","\\SERVER1\Enquiry"
else
End If
If Memberof(ObjGroupDict, "KidOps Users K") Then
wshNetwork.MapNetworkDrive "G:","\\SERVER1\KidOps"
else
End If
If Memberof(ObjGroupDict, "Minitab Users K") Then
wshNetwork.MapNetworkDrive "G:","\\SERVER1\Minitab"
else
End If
If Memberof(ObjGroupDict, "EssbaseGrp Users K") Then
wshNetwork.MapNetworkDrive "X:","\\SERVER1\EssBaseBKP"
else
End If
If Memberof(ObjGroupDict, "H & S Users K") Then
wshNetwork.MapNetworkDrive "V:","\\SERVER1\H&S"
else
End If
If Memberof(ObjGroupDict, "Quality Management Systems Users K") Then
wshNetwork.MapNetworkDrive "R:","\\SERVER1\Quality Management Systems"
else
End If
If Memberof(ObjGroupDict, "Work Instructions Users K") Then
wshNetwork.MapNetworkDrive "I:","\\SERVER1\Work Instructions"
else
End If
If Memberof(ObjGroupDict, "Complaints Users K") Then
wshNetwork.MapNetworkDrive "K:","\\SERVER3\Complaints"
else
End If
If Memberof(ObjGroupDict, "Finance Payroll Users K") Then
wshNetwork.MapNetworkDrive "W:","\\SERVER1\Statutory Financial"
else
End If
If Memberof(ObjGroupDict, "Msds Uni read Only U") Then
wshNetwork.MapNetworkDrive "M:","\\SERVER1\MSDS"
else
End If
If Memberof(ObjGroupDict, "Management Team Users K") Then
wshNetwork.MapNetworkDrive "X:","\\SERVER1\Management Team"
else
End If
' **** ADDED SECTION by RobSampson ****
Const OverwriteExisting = True
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FolderExists("C:\Windows\ctheme") = False Then objFSO.CreateFolder "C:\Windows\ctheme"
objFSO.CopyFile "\\server\shared\theme\*" , "c:\windows\ctheme\" , OverwriteExisting
Set objShell = CreateObject("Wscript.Shell")
objShell.Run "regedit /s \\server\shared\theme\reg\reg1.reg", 0, True
objShell.Run "regedit /s \\server\shared\theme\reg\reg2.reg", 0, True
objShell.Run "regedit /s \\server\shared\theme\reg\reg3.reg", 0, True
' *************************************
' Added By SJE
Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.run ("s:\share\client *echo-")
Function MemberOf(ObjDict, strKey)
' Given a Dictionary object containing groups to which the user
' is a member of and a group name, then returns True if the group
' is in the Dictionary else return False.
'
' Inputs:
' strDict - Input, Name of a Dictionary object
' strKey - Input, Value being searched for in
' the Dictionary object
' Sample Usage:
'
' If MemberOf(ObjGroupDict, "DOMAIN ADMINS") Then
' wscript.echo "Is a member of Domain Admins."
' End If
'
'
MemberOf = CBool(ObjGroupDict.Exists(strKey))
End Function
Function CreateMemberOfObject(strDomain, strUserName)
' Given a domain name and username, returns a Dictionary
' object of groups to which the user is a member of.
'
' Inputs:
'
' strDomain - Input, NT Domain name
' strUserName - Input, NT username
'
Dim objUser, objGroup
Set CreateMemberOfObject = CreateObject("Scripting.Dictionary")
CreateMemberOfObject.CompareMode = vbTextCompare
Set objUser = GetObject("WinNT://" _
& strDomain & "/" _
& strUserName & ",user")
For Each objGroup In objUser.Groups
CreateMemberOfObject.Add objGroup.Name, "-"
Next
Set objUser = Nothing
End Function
ASKER
Option Explicit ' Force explicit declarations
'
' Variables
'
Dim WSHNetwork
Dim FSO
Dim strUserName ' Current user
Dim strUserDomain ' Current User's domain name
Dim ObjGroupDict ' Dictionary of groups to which the user belongs
'on error resume next
Set WSHNetwork = WScript.CreateObject("WScript.Network")
Set FSO = CreateObject("Scripting.FileSystemObject")
'
' Wait until the user is really logged in...
'
strUserName = ""
While strUserName = ""
WScript.Sleep 100 ' 1/10 th of a second
strUserName = WSHNetwork.UserName
Wend
strUserDomain = WSHNetwork.UserDomain
' WScript.Echo "Running from Sysvol\domain\Scripts"
' Read the user's account "Member Of" tab info across the network
' once into a dictionary object.
Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.run "\\server1\netlogon\kidtheme.vbs", 0
'Map Common network Drives here, UNREM the below lines:
WSHNetwork.MapNetworkDrive "U:", "\\SERVER1\" & strUserName & "$"
WSHNetwork.MapNetworkDrive "S:", "\\SERVER1\Shared"
WSHNetwork.MapNetworkDrive "L:", "\\SERVER2\" & strUserName & "$"
Set ObjGroupDict = CreateMemberOfObject(strUserDomain, strUserName)
If Memberof(ObjGroupDict, "Accounts Users K") Then
wshNetwork.MapNetworkDrive "V:","\\SERVER1\Accounts"
else
End If
If Memberof(ObjGroupDict, "IT Users K") Then
wshNetwork.MapNetworkDrive "V:","\\SERVER1\It"
else
End If
If Memberof(ObjGroupDict, "Analytical Services Users K") Then
wshNetwork.MapNetworkDrive "J:","\\SERVER1\RootJ"
wshNetwork.MapNetworkDrive "W:","\\SERVER1\SAServices"
wshNetwork.MapNetworkDrive "V:","\\SERVER1\ASvcs"
else
End If
If Memberof(ObjGroupDict, "Administration Users S") Then
' WScript.Echo "Admin Users S"
wshNetwork.MapNetworkDrive "G:","\\SERVER3\Admin"
else
End If
If Memberof(ObjGroupDict, "Sudops Users S") Then
wshNetwork.MapNetworkDrive "F:","\\SERVER3\Sudops"
else
End If
If Memberof(ObjGroupDict, "Management Users S") Then
wshNetwork.MapNetworkDrive "H:","\\SERVER3\Management"
else
End If
If Memberof(ObjGroupDict, "Engineer Users K") Then
wshNetwork.MapNetworkDrive "V:","\\SERVER1\Engineer"
else
End If
If Memberof(ObjGroupDict, "MSDS Users K") Then
wshNetwork.MapNetworkDrive "M:","\\SERVER1\MSDS"
else
End If
'If Memberof(ObjGroupDict, "Engineer Proj Users K") Then
'wshNetwork.MapNetworkDrive "P:","\\SERVER1\EngProj"
'else
'End If
If Memberof(ObjGroupDict, "Base Colour & QC Users K") Then
wshNetwork.MapNetworkDrive "T:","\\SERVER1\Base_Colour"
else
End If
If Memberof(ObjGroupDict, "Base Colour Users K") Then
wshNetwork.MapNetworkDrive "V:","\\SERVER1\Base_Colour"
else
End If
If Memberof(ObjGroupDict, "QCGrp Users K") Then
wshNetwork.MapNetworkDrive "V:","\\SERVER1\QC"
wshNetwork.MapNetworkDrive "J:","\\SERVER1\RootJ"
else
End If
If Memberof(ObjGroupDict, "AdminGrp Users K") Then
wshNetwork.MapNetworkDrive "V:","\\SERVER1\AdminGrp"
else
End If
If Memberof(ObjGroupDict, "PDSA2 Users K") Then
wshNetwork.MapNetworkDrive "W:","\\SERVER1\PDSA2"
else
End If
If Memberof(ObjGroupDict, "Customer Users K") Then
wshNetwork.MapNetworkDrive "V:","\\SERVER1\Customer"
wshNetwork.MapNetworkDrive "W:","\\SERVER1\eWork"
else
End If
If Memberof(ObjGroupDict, "Marketing Users K") Then
wshNetwork.MapNetworkDrive "N:","\\SERVER1\Marketing"
else
End If
If Memberof(ObjGroupDict, "Sales Users K") Then
wshNetwork.MapNetworkDrive "P:","\\SERVER1\Sales"
else
End If
If Memberof(ObjGroupDict, "C Of A Admin Users K") Then
wshNetwork.MapNetworkDrive "T:","\\SERVER1\CofA"
else
End If
If Memberof(ObjGroupDict, "C of A View Users K") Then
wshNetwork.MapNetworkDrive "T:","\\SERVER1\CofA"
else
End If
If Memberof(ObjGroupDict, "TechEnq Users K") Then
wshNetwork.MapNetworkDrive "O:","\\SERVER1\TechEnq"
else
End If
If Memberof(ObjGroupDict, "TechEnqFA Users K") Then
wshNetwork.MapNetworkDrive "O:","\\SERVER1\TechEnq"
else
End If
If Memberof(ObjGroupDict, "Enquiry Users K") Then
wshNetwork.MapNetworkDrive "Q:","\\SERVER1\Enquiry"
else
End If
If Memberof(ObjGroupDict, "KidOps Users K") Then
wshNetwork.MapNetworkDrive "G:","\\SERVER1\KidOps"
else
End If
If Memberof(ObjGroupDict, "Minitab Users K") Then
wshNetwork.MapNetworkDrive "G:","\\SERVER1\Minitab"
else
End If
If Memberof(ObjGroupDict, "EssbaseGrp Users K") Then
wshNetwork.MapNetworkDrive "X:","\\SERVER1\EssBaseBKP"
else
End If
If Memberof(ObjGroupDict, "H & S Users K") Then
wshNetwork.MapNetworkDrive "V:","\\SERVER1\H&S"
else
End If
If Memberof(ObjGroupDict, "Quality Management Systems Users K") Then
wshNetwork.MapNetworkDrive "R:","\\SERVER1\Quality Management Systems"
else
End If
If Memberof(ObjGroupDict, "Work Instructions Users K") Then
wshNetwork.MapNetworkDrive "I:","\\SERVER1\Work Instructions"
else
End If
If Memberof(ObjGroupDict, "Complaints Users K") Then
wshNetwork.MapNetworkDrive "K:","\\SERVER3\Complaints"
else
End If
If Memberof(ObjGroupDict, "Finance Payroll Users K") Then
wshNetwork.MapNetworkDrive "W:","\\SERVER1\Statutory Financial"
else
End If
If Memberof(ObjGroupDict, "Msds Uni read Only U") Then
wshNetwork.MapNetworkDrive "M:","\\SERVER1\MSDS"
else
End If
If Memberof(ObjGroupDict, "Management Team Users K") Then
wshNetwork.MapNetworkDrive "X:","\\SERVER1\Management Team"
else
End If
' **** ADDED SECTION by RobSampson ****
Const OverwriteExisting = True
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FolderExists("C:\Windows\ctheme") = False Then objFSO.CreateFolder "C:\Windows\ctheme"
objFSO.CopyFile "\\server\shared\theme\*" , "c:\windows\ctheme\" , OverwriteExisting
Set objShell = CreateObject("Wscript.Shell")
objShell.Run "regedit /s \\server\shared\theme\reg\reg1.reg", 0, True
objShell.Run "regedit /s \\server\shared\theme\reg\reg2.reg", 0, True
objShell.Run "regedit /s \\server\shared\theme\reg\reg3.reg", 0, True
' *************************************
' Added By SJE
'Dim WshShell
'Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.run ("s:\share\client *echo-")
Function MemberOf(ObjDict, strKey)
' Given a Dictionary object containing groups to which the user
' is a member of and a group name, then returns True if the group
' is in the Dictionary else return False.
'
' Inputs:
' strDict - Input, Name of a Dictionary object
' strKey - Input, Value being searched for in
' the Dictionary object
' Sample Usage:
'
' If MemberOf(ObjGroupDict, "DOMAIN ADMINS") Then
' wscript.echo "Is a member of Domain Admins."
' End If
'
'
MemberOf = CBool(ObjGroupDict.Exists(strKey))
End Function
Function CreateMemberOfObject(strDomain, strUserName)
' Given a domain name and username, returns a Dictionary
' object of groups to which the user is a member of.
'
' Inputs:
'
' strDomain - Input, NT Domain name
' strUserName - Input, NT username
'
Dim objUser, objGroup
Set CreateMemberOfObject = CreateObject("Scripting.Dictionary")
CreateMemberOfObject.CompareMode = vbTextCompare
Set objUser = GetObject("WinNT://" _
& strDomain & "/" _
& strUserName & ",user")
For Each objGroup In objUser.Groups
CreateMemberOfObject.Add objGroup.Name, "-"
Next
Set objUser = Nothing
End Function
ASKER
ASKER
Microsoft Windows XP is the sixth release of the NT series of operating systems, and was the first to be marketed in a variety of editions: XP Home and XP Professional, designed for business and power users. The advanced features in XP Professional are generally disabled in Home Edition, but are there and can be activated. There were two 64-bit editions, an embedded edition and a tablet edition.
TRUSTED BY
set objShell = CreateObject("Wscript.Shel
To add individual values in vbscript, see the examples in these articles:
http://www.microsoft.com/technet/scriptcenter/resources/qanda/jun08/hey0624.mspx
http://www.microsoft.com/technet/scriptcenter/resources/qanda/feb05/hey0224.mspx
Keep in mind that since this is a logon script, users will have to have permission to the keys you're modifying.
For checking whether a file exists before copying it, see the example here:
http://www.devguru.com/Technologies/vbscript/QuickRef/filesystemobject_copyfile.html
Change the If to If Not and use the path of the destination file instead of the source file.