I decided to start a New Post. The other one was getting too big and long.
I'm using a batch file to call this vbscript and I'm not sure whether that's causing any problems. My company has an OU and I don't have access to GPO, I'm only allowed to manage my OU.
Here is my current vbscript, with the server name xxxx out.
It's hard to know why it's acting this way. It's working for only one user and others in the same Group/OU it's not running and no errors.
Basically. I'm trying to accomplish three objectives:
1. Map drives based on Group membership
2. Install Network printers also based on group membership
3. Set Default printers also group membership
4. Welcome Message: Good Morning. Evening
5. Html IE annoucement page.
Mark's Vbscript has been very helpful but I can't make it run?
See the script below..
Thanks,
'===========================================================
'
' NAME: LogonScript.vbs
'
' AUTHOR: Mark D. MacLachlan, The Spider's Parlor
' URL : ' DATE : 4/10/2003
'
' COMMENT: Enumerates current users' group memberships in given domain.
'
'==========================================================================
ON ERROR RESUME NEXT
Dim WSHShell, WSHNetwork, objDomain, DomainString, UserString, UserObj, Path
Set WSHShell = CreateObject("WScript.Shell")
Set WSHNetwork = CreateObject("WScript.Network")
Set objDomain = getObject("LDAP://rootDse")
DomainString = objDomain.Get("dnsHostName")
UserString = WSHNetwork.UserName
'Bind to the user object to get user name and check for group memberships later
Set UserObj = GetObject("WinNT://" & DomainString & "/" & UserString)
'Synchronizes the time with Server our NTP Server
WSHShell.Run "NET TIME \\xxx/set /y"
'Disconnect any drive mappings as needed.
WSHNetwork.RemoveNetworkDrive "F:"
'Disconnect ALL mapped drives
Set clDrives = WshNetwork.EnumNetworkDrives
For i = 0 to clDrives.Count -1 Step 2
WSHNetwork.RemoveNetworkDrive clDrives.Item(i)
Next
'Give the PC time to do the disconnect, wait 300 milliseconds
wscript.sleep 300
'Now check for group memberships and map appropriate drives
For Each GroupObj In UserObj.Groups
Select Case UCase(GroupObj.Name)
'Check for group memberships and take needed action
Case "MCF ADMIN"
WSHNetwork.MapNetworkDrive "r:", "\\xxx\SCAN",True
WSHNetwork.MapNetworkDrive "m:", "\\xxx\cristest",True
WSHNetwork.MapNetworkDrive "p:", "\\xxx\common",True
WSHNetwork.MapNetworkDrive "u:", "\\xxx\PUBLIC",True
WSHNetwork.AddWindowsPrinterConnection "\\xxx\mcf-ADMIN"
WSHNetwork.SetDefaultPrinter "\\xxx\mcf-ADMIN"
WSHNetwork.AddWindowsPrinterConnection "\\xxx\mcf-Xerox"
Case "MCF DISPATCH"
WSHNetwork.MapNetworkDrive "U:", "\\xxx\PUBLIC",True
WSHNetwork.MapNetworkDrive "m:", "\\xxx\cristest",True
WSHNetwork.MapNetworkDrive "p:", "\\xxx\common",True
WSHNetwork.AddWindowsPrinterConnection "\\xxx\mcf-Dispatch"
WSHNetwork.SetDefaultPrinter "\\xxx\mcf-Dispatch"
WSHNetwork.AddWindowsPrinterConnection "\\xxx\mcf-ADMIN"
End Select
'=====================================
Dim tempiepath
tempiepath = "HKCU\Software\Microsoft\Windows\"
WSHShell.RegWrite tempiepath & "ShellNoRoam\MUICache\@inetcplc.dll,-4750","Empty Temporary Internet Files folder when browser is closed","REG_SZ"
WSHShell.RegWrite tempiepath & "CurrentVersion\Internet Settings\Cache\Persistent","0","REG_DWORD"
Set tempiepath = nothing
'=====================================
HKEY_CURRENT_USER = &H80000001
strComputer = WSHNetwork.Computername
Set objReg = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "Control Panel\Desktop"
objReg.CreateKey HKEY_CURRENT_USER, strKeyPath
ValueName = "PaintDesktopVersion"
dwValue = 1
objReg.SetDWORDValue HKEY_CURRENT_USER, strKeyPath, ValueName, dwValue
'=======================================================
' Determine the appropriate greeting for the time of day.
'=======================================================
Dim HourNow, Greeting
HourNow = Hour(Now)
If HourNow >5 And HourNow <12 Then
Greeting = "Good Morning "
Elseif HourNow =>12 And HourNow <16 Then
Greeting = "Good Afternoon "
Else
Greeting = "Good Evening "
End If
Next
'=====================================
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists("\\server\Welcome\message.txt") Then
strText = objFSO.OpenTextFile("\\xxx\Welcome\Message.txt", 1).ReadAll
Set objIE = CreateObject("InternetExplorer.Application")
objIE.navigate2 "about:blank" : objIE.width = 350 : objIE.height = 480 : objIE.toolbar = false : objIE.menubar = false : objIE.statusbar = false : objIE.visible = True
objIE.document.write "<font color=blue>"
objIE.document.write "<h1>Important Announcement</h1>"
objIE.document.write strText
objIE.document.write "</font>"
End If
'Clean Up Memory We Used
set UserObj = Nothing
set GroupObj = Nothing
set WSHNetwork = Nothing
set DomainString = Nothing
set WSHSHell = Nothing
Set WSHPrinters = Nothing
'Quit the Script
wscript.quit
I'm using a batch file to call this vbscript and I'm not sure whether that's causing any problems. My company has an OU and I don't have access to GPO, I'm only allowed to manage my OU.
Here is my current vbscript, with the server name xxxx out.
It's hard to know why it's acting this way. It's working for only one user and others in the same Group/OU it's not running and no errors.
Basically. I'm trying to accomplish three objectives:
1. Map drives based on Group membership
2. Install Network printers also based on group membership
3. Set Default printers also group membership
4. Welcome Message: Good Morning. Evening
5. Html IE annoucement page.
Mark's Vbscript has been very helpful but I can't make it run?
See the script below..
Thanks,
'===========================================================
'
' NAME: LogonScript.vbs
'
' AUTHOR: Mark D. MacLachlan, The Spider's Parlor
' URL : ' DATE : 4/10/2003
'
' COMMENT: Enumerates current users' group memberships in given domain.
'
'==========================================================================
ON ERROR RESUME NEXT
Dim WSHShell, WSHNetwork, objDomain, DomainString, UserString, UserObj, Path
Set WSHShell = CreateObject("WScript.Shell")
Set WSHNetwork = CreateObject("WScript.Network")
Set objDomain = getObject("LDAP://rootDse")
DomainString = objDomain.Get("dnsHostName")
UserString = WSHNetwork.UserName
'Bind to the user object to get user name and check for group memberships later
Set UserObj = GetObject("WinNT://" & DomainString & "/" & UserString)
'Synchronizes the time with Server our NTP Server
WSHShell.Run "NET TIME \\xxx/set /y"
'Disconnect any drive mappings as needed.
WSHNetwork.RemoveNetworkDrive "F:"
'Disconnect ALL mapped drives
Set clDrives = WshNetwork.EnumNetworkDrives
For i = 0 to clDrives.Count -1 Step 2
WSHNetwork.RemoveNetworkDrive clDrives.Item(i)
Next
'Give the PC time to do the disconnect, wait 300 milliseconds
wscript.sleep 300
'Now check for group memberships and map appropriate drives
For Each GroupObj In UserObj.Groups
Select Case UCase(GroupObj.Name)
'Check for group memberships and take needed action
Case "MCF ADMIN"
WSHNetwork.MapNetworkDrive "r:", "\\xxx\SCAN",True
WSHNetwork.MapNetworkDrive "m:", "\\xxx\cristest",True
WSHNetwork.MapNetworkDrive "p:", "\\xxx\common",True
WSHNetwork.MapNetworkDrive "u:", "\\xxx\PUBLIC",True
WSHNetwork.AddWindowsPrinterConnection "\\xxx\mcf-ADMIN"
WSHNetwork.SetDefaultPrinter "\\xxx\mcf-ADMIN"
WSHNetwork.AddWindowsPrinterConnection "\\xxx\mcf-Xerox"
Case "MCF DISPATCH"
WSHNetwork.MapNetworkDrive "U:", "\\xxx\PUBLIC",True
WSHNetwork.MapNetworkDrive "m:", "\\xxx\cristest",True
WSHNetwork.MapNetworkDrive "p:", "\\xxx\common",True
WSHNetwork.AddWindowsPrinterConnection "\\xxx\mcf-Dispatch"
WSHNetwork.SetDefaultPrinter "\\xxx\mcf-Dispatch"
WSHNetwork.AddWindowsPrinterConnection "\\xxx\mcf-ADMIN"
End Select
'=====================================
Dim tempiepath
tempiepath = "HKCU\Software\Microsoft\Windows\"
WSHShell.RegWrite tempiepath & "ShellNoRoam\MUICache\@inetcplc.dll,-4750","Empty Temporary Internet Files folder when browser is closed","REG_SZ"
WSHShell.RegWrite tempiepath & "CurrentVersion\Internet Settings\Cache\Persistent","0","REG_DWORD"
Set tempiepath = nothing
'=====================================
HKEY_CURRENT_USER = &H80000001
strComputer = WSHNetwork.Computername
Set objReg = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "Control Panel\Desktop"
objReg.CreateKey HKEY_CURRENT_USER, strKeyPath
ValueName = "PaintDesktopVersion"
dwValue = 1
objReg.SetDWORDValue HKEY_CURRENT_USER, strKeyPath, ValueName, dwValue
'=======================================================
' Determine the appropriate greeting for the time of day.
'=======================================================
Dim HourNow, Greeting
HourNow = Hour(Now)
If HourNow >5 And HourNow <12 Then
Greeting = "Good Morning "
Elseif HourNow =>12 And HourNow <16 Then
Greeting = "Good Afternoon "
Else
Greeting = "Good Evening "
End If
Next
'=====================================
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists("\\server\Welcome\message.txt") Then
strText = objFSO.OpenTextFile("\\xxx\Welcome\Message.txt", 1).ReadAll
Set objIE = CreateObject("InternetExplorer.Application")
objIE.navigate2 "about:blank" : objIE.width = 350 : objIE.height = 480 : objIE.toolbar = false : objIE.menubar = false : objIE.statusbar = false : objIE.visible = True
objIE.document.write "<font color=blue>"
objIE.document.write "<h1>Important Announcement</h1>"
objIE.document.write strText
objIE.document.write "</font>"
End If
'Clean Up Memory We Used
set UserObj = Nothing
set GroupObj = Nothing
set WSHNetwork = Nothing
set DomainString = Nothing
set WSHSHell = Nothing
Set WSHPrinters = Nothing
'Quit the Script
wscript.quit