Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sharing your login scripts

Status
Not open for further replies.

pgordemer

IS-IT--Management
Dec 10, 2002
80
0
0
US
In the spirit of teaching others and showing what I have learned lurking here, I thought I would dump my latest login script (in the next message) as it uses many of the tips and tricks discusssed in this group by Mark and others.

So lets share our scripts so we can see what we have learned. There is nothing in this script that is a security issue so I feel comfortable sharing it. Feel free to copy what you want, also if you think I could do somethings better please let me know. I am aways learning.

FWIW, don't let the script length fool you, it only takes about 5 seconds to do the entire thing.

Phil Gordemer
ARH Associates
 
'---------- ARHLOGON.VBS --------------------------------------------------
' Logon script running in GPO for all computers in ARH Network.
'--------------------------------------------------------------------------
' To avoid having different logon scripts for different offices & computers,
' this script will determine your location by querying your IP address
' or from a command line argument. User information and location
' information are then combined to remove old drive mappings, attach
' new drive mappings, update support software, stardardize settings,etc.
' Each section is documented and fairly obvious what is happening.
'
' The script is deployed to the workstations in a GPO in the Active
' Directory ARH-US.COM. Policy name is ARH CUSTOMIZED.
'
' To protect from run-away scripts, this will NOT map drive letters
' if run As ADMINISTRATOR.
'
' Author: Phil Gordemer
'
' Credits:
' Logic, structure and code segments gleaned and used from
' Mark D. MacLachlan, The Spiders Parlor
' Mr Movie
' Bill Paterson
' Tek Tips VB Script Forum
'
' Sub and Parts logic credited to
'
' ARHLOGON /VPN /CS /HQ /NORTH /SILENT /UPDATE /?
'
' /VPN
' Logon is from VPN, assume HQ location
' /CS
' Force CS location
' /HQ
' Force HQ location
' /NORTH
' Force NORTH location
' /SILENT
' No screen display - non interactive
' /UPDATE
' Force update even if registry key exists
' /?
' This help screen
'--------------------------------------------------------------------------
' 12/14/05 V3.0.1
' Remove regedit for Language bar
' 12/14/05 V3.0.0
' Major Restructuring
' New function to test that servers are alive
' Change most sections to react to dead servers
' Change location of TrakPC posting
' 12/08/05 V2.6.7
' Stop creation of PDF Factory for troublshooting
' 12/06/05 V2.6.6
' Add ARH2 ARH3 servers to IE Trusted Zones
' Removed WIND2 1 time update
' Removed ACAD Link 1 time update
' Update printers for new North Server
'-----------------------------------------------------------------------
' NOTES for changes from 1.0.0 to 2.6.5 have been removed to
' archive
'-----------------------------------------------------------------------

On Error Resume Next

Dim WSHShell, WSHNetwork
Dim objFSO, objDomain, objWMI
Dim UserString, UserObj, GroupObj
Dim strHomeShare, strComputer
Dim MSIE, WinDir
Const WaitonReturn = True , NoWaitonReturn = False
Const HideWindow = 0 ,DisplayWindow = 1
Const OverWrite = True
Const Force = True
Const UpdateProfile = True
VPN = False
CS = False
HQ = False
NORTH = False
StayOpen = False
Silent = False
Update = False
UptoDate = False
Administrator = False

Version = "v3.0.1"

Set WSHShell = CreateObject("WScript.Shell")
Set WSHNetwork = CreateObject("WScript.Network")
Set objFSO = CreateObject("Scripting.FileSystemObject")

'---------- Check the command line for arguments --------------------------
Set objArgs = WScript.Arguments
For i = 0 To objArgs.Count - 1
strCommandLine = objArgs(i)
Select Case UCase(strCommandLine)
Case "/VPN"
VPN = True
Case "/SILENT"
Silent = True
Case "/CS"
CS = True
Case "/HQ"
HQ = True
Case "/NORTH"
NORTH = True
Case "/UPDATE"
Update = True
Case "/?"
MsgBox "ARHLOGON.VBS" & vbCRLF & _
"Logon script for computers in ARH Network" & vbCRLF & vbCRLF & _
" ARHLOGON /VPN /CS /HQ /NORTH /SILENT /?" & vbCRLF & vbCRLF & _
" /VPN" & vbCRLF & _
" Logon is from VPN, assume HQ location" & vbCRLF & _
" /CS" & vbCRLF & _
" Force CS location" & vbCRLF & _
" /HQ" & vbCRLF & _
" Force HQ location" & vbCRLF & _
" /NORTH" & vbCRLF & _
" Force NORTH location" & vbCRLF & _
" /SILENT" & vbCRLF & _
" No screen display - non interactive" & vbCRLF & _
" /UPDATE" & vbCRLF & _
" Force update even if registry key exists" & vbCRLF & _
" /?" & vbCRLF & _
" This help screen" & vbCRLF & vbCRLF
WScript.Quit
End Select
Next

'---------- Use Internet Explorer to display where we are going -----------
setupMSIE

'---------- Check registry to see last version run ------------------------
RegKeyARH = "HKCU\Software\ARH\LogonCustomization\Version"
If KeyExists (RegkeyARH) Then
If WSHShell.RegRead(RegKeyARH) = Version Then
UptoDate = True
End If
End If
If Update Then UptoDate = False

'---------- Get some local computer information -------------------------
' Get Windows directory location
WinDir = objFSO.GetSpecialFolder(0)
' Get User Profile directory location
UserProfile = WSHShell.ExpandEnvironmentStrings("%UserProfile%")

'---------- Find their OS to determine who is a server or workstation -----
OS2000 = False
OSXP = False
OSXP64 = False
OSServer2003 = False
OSServer2000 = False
WorkStation = False
Server = False
Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colOperatingSystems = objWMI.ExecQuery ("Select * from Win32_OperatingSystem")
For Each objOperatingSystem In colOperatingSystems
OSName = objOperatingSystem.Caption
Select Case OSname
Case "Microsoft Windows 2000 Professional"
OS2000 = True
WorkStation = True
Case "Microsoft Windows XP Professional"
OSXP = True
WorkStation = True
Case "Microsoft(R) Windows(R) XP Professional x64 Edition"
OSXP64 = True
WorkStation = True
Case "Microsoft Windows 2000 Server"
OSServer2000 = True
Server = True
Case "Microsoft(R) Windows(R) Server 2003, Standard Edition"
OSServer2003 = True
Server = True
Case Else
showIE "BRed", "<BR><BR>" & OSName
showIE "", "<BR><BR>OS not known, aborting script"
StayOpen = True
Cleanup StayOpen
End Select
Next

'----------Find their location --------------------------------------------
' 192.168.0.x is HQ
' 192.168.1.x is CS
' 192.168.2.x is North
Location = "UNKNOWN"
If CS Then Location = "CS"
If NORTH Then Location = "NORTH"
If HQ Then Location = "HQ"
If VPN Then Location = "HQ"
If Location = "UNKNOWN" Then
Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set myobj = objWMI.ExecQuery("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled = True")
For Each itm In myobj
arrIP = Split(itm.IPAddress(0),".")
If arrIP(0) = 192 And arrIP(1) = 168 Then
If arrIP(2) = 2 Then
Location = "NORTH"
End If
If arrIP(2) = 1 Then
Location = "CS"
End If
If arrIP(2) = 0 Then
Location = "HQ"
End If
End If
Next
End If
If Location = "UNKNOWN" Then
showIE "BRed", "<BR><BR>Location unknown, aborting script"
StayOpen = True
Cleanup StayOpen
End If

'---------- Get information from Active directory -------------------------
' Grab the user name and computer name and home directory, set a flag
' if logged in as Administrator
UserString = UCase(WSHNetwork.UserName)
If UserString = "ADMINISTRATOR" Then
Administrator = True
End If
strComputer = UCase(WSHNetwork.ComputerName)
showIE "Yellow","Connecting "
showIE "BRed", UserString
showIE "Yellow", " on "
showIE "BRed", strComputer
showIE "BRed", "<BR>" & OSName & "<BR>"
showIE "White", "Detected location is " & Location & "<BR>"
Set UserObj = GetObject("WinNT://ARH-NT/" & UserString)
strHomeShare = UCase(UserObj.HomeDirectory)

'---------- Disconnect ALL mapped drives except H: ------------------------
' Need to insert a slight pause between each disconnect to give
' time for the registry to update
showIE "Yellow", "<BR>Removing drives: "
Set clDrives = WshNetwork.EnumNetworkDrives
For i = 0 To clDrives.Count -1 Step 2
If clDrives.Item(i) <> "H:" Then
showIE "",clDrives.Item(i) & " "
WSHNetwork.RemoveNetworkDrive clDrives.Item(i), Force, UpdateProfile
WScript.sleep 100
End If
Next
WScript.sleep 300

'---------- Map drives needed by all --------------------------------------
' Home Drive
showIE "White", "<BR>Mapping Home Drive H: to: "
If objFSO.DriveExists("H:") Then
showIE "", " Already Done"
Else
WSHNetwork.MapNetworkDrive "H:", strHomeShare
showIE "", " " & strHomeShare
End If


'---------- Map Drives by Location ----------------------------------------
' Even though the drive mappings are mostly the same we are seperating them
' and duplicating for more felxibility. Don't map drives if logged in as
' administrator. Check to make sure the server is alive before mapping
' to it
showIE "Yellow", "<BR>Mapping Drives: "
If Not Administrator Then
Select Case Location
Case "HQ"
If IsAlive("ARH1") Then
showIE "", " ARH1"
WSHNetwork.MapNetworkDrive "M:", "\\arh1\CAD-STD"
WSHNetwork.MapNetworkDrive "N:", "\\arh1\vol2"
WSHNetwork.MapNetworkDrive "P:", "\\arh1\fileroom"
WSHNetwork.MapNetworkDrive "S:", "\\arh1\shared"
WSHNetwork.MapNetworkDrive "T:", "\\arh1\temp"
End If
If IsAlive("ARH-CS") Then
showIE "", " ARH-CS"
WSHNetwork.MapNetworkDrive "G:", "\\arh-cs\gis-temp"
WSHNetwork.MapNetworkDrive "J:", "\\arh-cs\specs"
WSHNetwork.MapNetworkDrive "O:", "\\arh-cs\gis-4"
WSHNetwork.MapNetworkDrive "Q:", "\\arh-cs\gis-1"
WSHNetwork.MapNetworkDrive "R:", "\\arh-cs\gis-3"
WSHNetwork.MapNetworkDrive "U:", "\\arh-cs\gis-final"
WSHNetwork.MapNetworkDrive "V:", "\\arh-cs\fileroom"
End If
Case "CS"
If IsAlive("ARH-CS") Then
showIE "", " ARH-CS"
WSHNetwork.MapNetworkDrive "G:", "\\arh-cs\gis-temp"
WSHNetwork.MapNetworkDrive "J:", "\\arh-cs\specs"
WSHNetwork.MapNetworkDrive "O:", "\\arh-cs\gis-4"
WSHNetwork.MapNetworkDrive "Q:", "\\arh-cs\gis-1"
WSHNetwork.MapNetworkDrive "R:", "\\arh-cs\gis-3"
WSHNetwork.MapNetworkDrive "U:", "\\arh-cs\gis-final"
WSHNetwork.MapNetworkDrive "V:", "\\arh-cs\fileroom"
End If
If IsAlive("ARH1") Then
showIE "", " ARH1"
WSHNetwork.MapNetworkDrive "M:", "\\arh1\CAD-STD"
WSHNetwork.MapNetworkDrive "N:", "\\arh1\vol2"
WSHNetwork.MapNetworkDrive "P:", "\\arh1\fileroom"
WSHNetwork.MapNetworkDrive "S:", "\\arh1\shared"
WSHNetwork.MapNetworkDrive "T:", "\\arh1\temp"
End If
If IsAlive("CSIMS01") Then
showIE "", " CSIMS01"
WSHNetwork.MapNetworkDrive "L:", "\\csims01\csdata"
WSHNetwork.MapNetworkDrive "X:", "\\csims01\enterroadinfo"
End If
Case "NORTH"
If IsAlive("ARH-N") Then
showIE "", " ARH-N"
WSHNetwork.MapNetworkDrive "G:", "\\arh-n\vol1"
WSHNetwork.MapNetworkDrive "I:", "\\arh-n\vol1\survey"
WSHNetwork.MapNetworkDrive "M:", "\\arh-n\CAD-STD"
WSHNetwork.MapNetworkDrive "N:", "\\arh-n\vol2"
WSHNetwork.MapNetworkDrive "P:", "\\arh-n\fileroom"
WSHNetwork.MapNetworkDrive "S:", "\\arh-n\shared"
WSHNetwork.MapNetworkDrive "T:", "\\arh-n\temp"
WSHNetwork.MapNetworkDrive "W:", "\\arh-n\wind2"
End If
End Select
Else
showIE "", "Skipped as ADMINISTRATOR"
End If

'---------- Map Printers by Location --------------------------------------
' Map printers for workstations only
'
'Remove a specific printer
' WSHNetwork.RemovePrinterConnection "\\Server\PrinterName", Force, UpdateProfile
''Install Printers
' WSHNetwork.AddWindowsPrinterConnection "\\Server\PrinterName"
'Set Default Printer
' WSHNetwork.SetDefaultPrinter "\\ServerName\PrinterName"
'
showIE "White", "<BR>Mapping Printers: "
If Workstation Then
Select Case Location
Case "HQ"
If IsAlive("ARH1") Then
showIE "", " HQ - 7 Printers: "
WSHNetwork.AddWindowsPrinterConnection "\\ARH1\HP3550"
' WSHNetwork.AddWindowsPrinterConnection "\\ARH1\PDFFACT2"
WSHNetwork.AddWindowsPrinterConnection "\\ARH1\4plus"
WSHNetwork.AddWindowsPrinterConnection "\\ARH1\HP4-Sur"
WSHNetwork.AddWindowsPrinterConnection "\\ARH1\HP5M"
WSHNetwork.AddWindowsPrinterConnection "\\ARH1\HP5N-Muni"
WSHNetwork.AddWindowsPrinterConnection "\\ARH1\Kyoceracolor"
WSHNetwork.AddWindowsPrinterConnection "\\ARH1\LJ2200-Admin"
End If
Case "CS"
If IsAlive("ARH-CS") Then
showIE "", " CS - 8 Printers: "
WSHNetwork.AddWindowsPrinterConnection "\\ARH-CS\HP5-CS"
' WSHNetwork.AddWindowsPrinterConnection "\\ARH-CS\PDFFACT2"
WSHNetwork.AddWindowsPrinterConnection "\\ARH-CS\HP5M_RECEPT"
WSHNetwork.AddWindowsPrinterConnection "\\ARH-CS\TOSHIBA"
WSHNetwork.AddWindowsPrinterConnection "\\ARH-CS\CP1700"
WSHNetwork.AddWindowsPrinterConnection "\\ARH-CS\TCS-400MF"
WSHNetwork.AddWindowsPrinterConnection "\\ARH-CS\hp1055cm"
WSHNetwork.AddWindowsPrinterConnection "\\ARH-CS\HP5M-CS"
WSHNetwork.AddWindowsPrinterConnection "\\ARH-CS\Kyocera Mita KM-C850 KX"
End If
Case "NORTH"
If IsAlive("ARH-NORTH") Then
showIE "", " North - 6 Printers"
WSHNetwork.AddWindowsPrinterConnection "\\ARH-NORTH\HP1050C"
WSHNetwork.AddWindowsPrinterConnection "\\ARH-NORTH\KM1650"
WSHNetwork.AddWindowsPrinterConnection "\\ARH-NORTH\CP1700"
WSHNetwork.AddWindowsPrinterConnection "\\ARH-NORTH\HP755CM"
WSHNetwork.AddWindowsPrinterConnection "\\ARH-NORTH\MAGIC2200"
'WSHNetwork.AddWindowsPrinterConnection "\\ARH-NORTH\PDFFACT2"
End If
End Select
Else
showIE "", " Skipped as SERVER"
End If

'---------- Setup MS Office Paths to local server---------------------------
' Office templates are stored on local server in each office. Since a computer
' may be built in one office and sent to another, reset the shared templates
' location for where the computer is located. Note: if the SharedTemplates was
' never set on a computer, then the key won't exist, check for another key
' in the same folder.
showIE "Yellow", "<BR>Customizing MS Office: "
' Registry Key for Office 2003
RegKey1 = "HKCU\Software\Microsoft\Office\11.0\Common\General\Templates"
RegKey2 = "HKCU\Software\Microsoft\Office\11.0\Common\General\SharedTemplates"
If KeyExists (RegKey1) Then
Select Case Location
Case "HQ"
showIE "", "HQ OFFICE 2003"
WshShell.RegWrite Regkey2, "N:\ARH Templates", "REG_EXPAND_SZ"
Case "CS"
showIE "", "CS OFFICE 2003"
WshShell.RegWrite RegKey2, "Q:\ARH Templates", "REG_EXPAND_SZ"
Case "NORTH"
showIE "", "NORTH OFFICE 2003"
WshShell.RegWrite Regkey2, "G:\ARH Templates", "REG_EXPAND_SZ"
End Select
End If
' Registry Key for Office XP
RegKey1 = "HKCU\Software\Microsoft\Office\10.0\Common\General\Templates"
RegKey2 = "HKCU\Software\Microsoft\Office\10.0\Common\General\SharedTemplates"
If KeyExists (Regkey1) Then
Select Case Location
Case "HQ"
showIE "", "HQ Office XP"
WshShell.RegWrite RegKey2, "N:\ARH Templates", "REG_EXPAND_SZ"
Case "CS"
showIE "", "CS Office XP"
WshShell.RegWrite RegKey2, "Q:\ARH Templates", "REG_EXPAND_SZ"
Case "NORTH"
showIE "", "NORTH Office XP"
WshShell.RegWrite RegKey2, "G:\ARH Templates", "REG_EXPAND_SZ"
End Select
End If

'---------- Actions based On group memberships ----------------------------
showIE "White", "<BR>Activating group items: "
For Each GroupObj In UserObj.Groups
Select Case UCase(GroupObj.Name)
Case "ADMINISTRATORS"
showIE "", "ADMINISTRATORS"
End Select
Next

'---------- Actions based on Computer name --------------------------------
showIE "Yellow", "<BR>Activating computer items: "
Select Case UCase (strComputer)
Case "DELL67"
showIE "","DELL67 default printer HP4"
WSHNetwork.SetDefaultPrinter "\\ARH1\HP5M"
Case Else
showIE "", "None "
End Select

'---------- Check they have all the support products ----------------------
showIE "White", "<BR>Checking HelpDesk Support Products"
' Create the Help Desk IE shortcut
strShortcut = WSHShell.SpecialFolders("Desktop") & "\ARH Helpdesk.lnk"
If Not objFSO.FileExists(strShortcut) Then
Set oUrlLink = WshShell.CreateShortcut(strShortcut)
oUrlLink.TargetPath = " oUrlLink.Save
End If
' Make sure inventory program is on their computer
If Not objFSO.FileExists("C:\trakpc.exe") Then
Select Case Location
Case "HQ"
objFSO.CopyFile "\\services-hq\disks\helpdesk\trakpc.exe", "C:\", OverWrite
Case "CS"
objFSO.CopyFile "\\services-cs\disks\helpdesk\trakpc.exe", "C:\", OverWrite
Case "NORTH"
objFSO.CopyFile "\\services-north\disks\helpdesk\trakpc.exe", "C:\", OverWrite
End Select
End If
If objFSO.FileExists("C:\Program Files\Autodesk Land Desktop 2006\acad.exe") Then
strShortcut2 = WSHShell.SpecialFolders("Desktop") & "\Update CAD.lnk"
If Not objFSO.FileExists(strShortcut2) Then
Set oUrlLink = WshShell.CreateShortcut(strShortcut2)
oUrlLink.TargetPath = "M:\ARHCAD2006\SETUP\UpdateCAD.vbs"
ourlLink.IconLocation = "C:\Program Files\Autodesk Land Desktop 2006\AcadLand.ico"
oUrlLink.Save
End If
End If

'---------- Run TRAKPC Inventory Program ----------------------------------
' Trakpc runs on the local computer and does a WMI inventory of the
' computer and uploads the results to the helpdesk site. Create a .cmd
' file to run the program, do not run it directly as it needs the
' cmd environment variables.
showIE "Yellow", "<BR>Running HelpDesk Inventory: "
Set objFile = objFSO.CreateTextFile("c:\invent.cmd", OverWrite)
objFile.WriteLine "C:"
objFile.WriteLine "CD\"
objFile.WriteLine "C:\trakpc.exe c:\ /q /u""objFile.Writeline "EXIT"
objFile.Close
WSHShell.Run "c:\invent.cmd", HideWindow , NoWaitonReturn
'showIE "", " Finished "

'---------- Create Standards & Write Registry Keys ------------------------
' Only run standards and regedits if ARH logon key does not match current version
showIE "White", "<BR>Standards Updates: "
If Not UptoDate Then
' Set OS Registered Organization to ARH Associates
WSHShell.RegWrite "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\RegisteredOrganization", "ARH Associates","REG_SZ"
' SET OS Registerd Owner to computer name
WSHShell.RegWrite "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\RegisteredOwner", strComputer,"REG_SZ"
If OSXP Then
' Add Domain Users to the Local Administrators group (Needed for ACAD and ARCMAP)
WshShell.Run "net localgroup ""Administrators"" ""ARH-NT\Domain Users"" /add", HideWindow, WaitonReturn
' Turn off Error reporting
wshShell.RegWrite "HKLM\Software\Microsoft\PCHealth\ErrorReporting\DoReport", 0, "REG_DWORD"
wshShell.RegWrite "HKLM\Software\Microsoft\PCHealth\ErrorReporting\ShowUI", 0, "REG_DWORD"
wshShell.RegWrite "HKLM\Software\Microsoft\PCHealth\ErrorReporting\IncludeKernelFaults", 0, "REG_DWORD"
wshShell.RegWrite "HKLM\Software\Microsoft\PCHealth\ErrorReporting\IncludeMicrosoftApps", 0, "REG_DWORD"
wshShell.RegWrite "HKLM\Software\Microsoft\PCHealth\ErrorReporting\IncludeWindowsApps", 0, "REG_DWORD"
' Turn off XP Windows setting started tour
WshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Applets\Tour\RunCount", 0, "REG_DWORD"
' Turn off XP .net password setup
WshShell.RegWrite "HKCU\Software\Microsoft\MessengerService\PassportBalloon", 10, "REG_BINARY"
' IE6 Add *.arh-us.com SP2 Popup Blocker
WSHShell.RegWrite "HKCU\Software\Microsoft\Internet Explorer\New Windows\Allow\*.arh-us.com", 0, "REG_BINARY"
End If
' Explorer Speed up browsing by not checking scheduled tasks
RegKey1 = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\RemoteComputer\NameSpace\{D6277990-4C6A-11CF-8D87-00AA0060F5BF}\"
If KeyExists(Regkey1) Then
WshShell.RegDelete RegKey1
End If
' Explorer File Manager - Disable thumbnail cache
WshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\DisableThumbnailCache", 1, "REG_DWORD"
' Explorer File Manager - show hidden files and folders
WshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Hidden", 1, "REG_DWORD"
' Explorer File Manager - show operating system files
WSHShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\SuperHidden", 1,"REG_DWORD"
WshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ShowSuperHidden", 1, "REG_DWORD"
' Explorer File Manager - show file extensions
WshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\HideFileExt", 0, "REG_DWORD"
' Explorer File Manager - show system files
WshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\WebViewBarricade", 1, "REG_DWORD"
' Explorer File Manager - Command Prompt Here
WshShell.RegWrite "HKCR\Folder\Shell\MenuText\Command\", "cmd.exe /k cd " & Chr(34) & "%1" & Chr(34)
WshShell.RegWrite "HKCR\Folder\Shell\MenuText\", "Command Prompt Here"
' IE6 Cache settings to 10 MB
WSHShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Cache\Content\CacheLimit", 10240,"REG_DWORD"
WSHShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\5.0\Cache\Content\CacheLimit", 10240,"REG_DWORD"
' IE6 History to 5 days
WSHShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Url History\DaysToKeep", 5,"REG_DWORD"
' IE6 No Update check
WSHShell.RegWrite "HKCU\Software\Microsoft\Internet Explorer\Main\NoUpdateCheck", 1,"REG_DWORD"
' IE6 Do not reuse windows
WSHShell.RegWrite "HKCU\Software\Microsoft\Internet Explorer\Main\AllowWindowReuse", 0,"REG_DWORD"
' IE6 Increase download limit to 10
WSHShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\MaxConnectionsPer1_0Server", 10,"REG_DWORD"
WSHShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\MaxConnectionsPerServer", 10,"REG_DWORD"
' IE6 Add servers to Trusted Zone
wshshell.regwrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\services-cs\file",2,"REG_DWORD"
wshshell.regwrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\services-hq\file",2,"REG_DWORD"
wshshell.regwrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\services-north\file",2,"REG_DWORD"
wshshell.regwrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\arh1\file",2,"REG_DWORD"
wshshell.regwrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\arh2\file",2,"REG_DWORD"
wshshell.regwrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\arh3\file",2,"REG_DWORD"
wshshell.regwrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\arh-north\file",2,"REG_DWORD"
wshshell.regwrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\arh-cs\file",2,"REG_DWORD"
wshshell.regwrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\helpdesk\file",2,"REG_DWORD"
' Rename My Computer to Computer Hostname
RenameMyComputer
ShowIE "", " Updated"
Else
ShowIE "", " Skipped"
End If

'--------- One Time Updates -----------------------------------------------
' Here is where to put 1 time updates, Program installs, things that can
' be removed once run once.
'
showIE "BRed", "<BR><BR>Updates: "
'
' Wind2 update and move. Only once per machine, so store key in
' HKLM instead of per user HKCU
' This entry can be removed after November 1, 2005
'If Not KeyExists ("HKLM\Software\ARH\LogonCustomization\Wind2Update") Then
' If objFSO.FileExists(WinDir & "\wind2.ini") Then
' ShowIE "", " WIND2 Update <BR>"
' ShowIE "", "This update will take 30 seconds"
' Select Case Location
' Case "HQ"
' objFSO.CopyFile "\\services-hq\disks\Wind2_Setup\Wind2.ini", WinDir & "\", OverWrite
' Case "CS"
' objFSO.CopyFile "\\services-cs\disks\Wind2_Setup\Wind2.ini", WinDir & "\", OverWrite
' Case "NORTH"
' ' Do not replace North office file yet, just put the marker there for now
' End Select
' End If
' WshShell.RegWrite "HKLM\Software\ARH\LogonCustomization\Wind2Update", Date, "REG_SZ"
'End If


'---------- Thats all folks -----------------------------------------------
' Write version of script run to Registry, then getout.
WshShell.RegWrite RegkeyARH, Version, "REG_SZ"
showIE "BBlack", "<BR>" & String(20, Chr(183)) & "Done!" & String(20, Chr(183))
WScript.Sleep 4000
Cleanup StayOpen


'---------- Subroutines ---------------------------------------------------

Sub Cleanup (StayOpen)
'----------House cleaning and get out ----------------------------------
If Not StayOpen Then
MSIE.Quit
End If
Set UserObj = Nothing
Set WSHNetwork = Nothing
Set WSHSHell = Nothing
Set MSIE = Nothing
Set objFSO = Nothing
Set objWMI = Nothing
WScript.quit
End Sub

Sub setupMSIE
'----------Setup IE to display what we are doing -----------------------
' Remember to DIM MSIE in main program
' MSIE.Document.Write "xxx" writes line using HTML
' MSIE.Quit closes IE Window
'-----------------------------------------------------------------------
If Silent Then Exit Sub
Set MSIE = CreateObject("InternetExplorer.Application")
MSIE.Navigate "About:Blank"
MSIE.Toolbar = False
MSIE.StatusBar = False
MSIE.Resizable = True
Do
WScript.sleep 100
Loop While MSIE.Busy
SWidth = MSIE.Document.ParentWindow.Screen.AvailWidth
SHeight = MSIE.Document.ParentWindow.Screen.AvailHeight
MSIE.Width = SWidth/2
MSIE.Height = SHeight/1.5
MSIE.Left = (SWidth - MSIE.Width)/2
MSIE.Top = (SHeight - MSIE.Height)/2
MSIE.Visible = True
MSIE.Document.Write "<html><title>ARH Network Logon " & Version & " </TITLE>"
MSIE.Document.Write "<body text=""#FFFF00"" bgcolor=""#00CC00"">"
End Sub

Sub showIE (strColor,strText)
'---------- Write strText to IE display --------------------------------
If Silent Then Exit Sub
Select Case strColor
Case "Yellow"
showColor = "<font color=""#FFFF00"">"
Case "White"
showColor = "<font color=""#FFFFFF"">"
Case "Red"
showColor = "<font color=""#FF0000"">"
Case "BRed"
showColor = "<font color=""#FF0000""><B>"
Case "Black"
showColor = "<font color=""#000000"">"
Case "BBlack"
showColor = "<font color=""#000000""><B>"
End Select
MSIE.Document.write showColor & strText & " </B>"
End Sub

Sub RenameMyComputer
'---------- Rename My Computer to computer hostname --------------------
Const MY_COMPUTER = &H11&
Set objNetwork = CreateObject("Wscript.Network")
objComputerName = objNetwork.ComputerName
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(MY_COMPUTER)
Set objFolderItem = objFolder.Self
objFolderItem.Name = objComputerName
Set objNetwork = Nothing
Set objShell = Nothing
End Sub

Function KeyExists (KeytoFind)
' Test to see if Registry Key exists before acting on it
Dim KeyTest
Set objShell = CreateObject("WScript.Shell")
On Error Resume Next
KeyTest = objShell.RegRead (KeytoFind)
If err <> 0 Then
KeyExists = False
Else
KeyExists = True
End If
Set objShell = Nothing
End Function

Function IsAlive(strHost)
' Test to see if host or url is alive through PING
Set objShell = CreateObject("WScript.Shell")
IsAlive = Not CBool(objShell.run("ping -n 1 " & strHost,0,True))
Set objShell = Nothing
End Function
 
Very nice.

I like that you have added sites to the Trusted sites. I may need to add that to my FAQ as an option.

You are doing a lot of registry writing. For faster processing, you may want to break that part into a different script and call it only if needed. Your users will need to parse less info on login that way.

I hope you find this post helpful.

Regards,

Mark
 
The part of the registry writes is only begin done ONCE per version number. It the version number matches what is in the registry, that whole section gets skipped.

'---------- Create Standards & Write Registry Keys ------------------------
' Only run standards and regedits if ARH logon key does not match current version
showIE "White", "<BR>Standards Updates: "
If Not UptoDate Then
' Set OS Registered Organization to ARH Associates
WSHShell.RegWrite "HKLM\SOFTWARE\

UptoDate flag gets set in the top of the program with a registry check.

Phil Gordemer
ARH Associates
 
I saw that. The script engine still needs to read the entire script to determine where to continue from though. That is what I was referring to.

You could be talking the difference of anywhere from milliseconds to a second, probably nothing noticeable to your users, but maybe...

I hope you find this post helpful.

Regards,

Mark
 
I just used Marks. His works great with a few modifications but not much. I did add our own add ons to his script to download the latest hosts file, download the latest sdat and install it silently as well as the option to run the latest stinger.exe from Mcafee when there is a virus scare ...

Code:
'Adds the HOSTS file
Const OverwriteExisting = TRUE
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "\\server\updates\hosts", WshShell.ExpandEnvironmentStrings("%systemroot%\system32\drivers\etc\"), OverwriteExisting
'=====================================
'This copies the SDAT.exe file to C:\ and then installs it with a silent switch
objFSO.CopyFile "\\server\updates\sdat.exe" , "c:\", OverwriteExisting
wshshell.run "c:\sdat.exe -s",,true
Set objFSO=Nothing
'=====================================
'Runs NAI Stinger - WARNING: Before you activate this portion of the script, make sure
'the latest stinger.exe was downloaded and resides in the location it's supposed to be.
'UnREM the next 2 lines for stinger to run ...

'objFSO.CopyFile "\\server\updates\stinger.exe" , "c:\", OverwriteExisting
'wshshell.run "c:\stinger.exe /ADL /GO /LOG /SILENT",,true
'=====================================

TT
 
MojoZig. I am curious, do you have any users that are allowed to modify the hosts file? If so what do you do to preserve any custom entries they may have created?

I've run into this a few times and what I do is append to the existing hosts file or change its contents if I know I am changing the IP of an entry that I previously created.

I hope you find this post helpful.

Regards,

Mark
 
Mark,

We don't allow them to modify the Hosts file. Our users are government employees and not very technical. We mainly used the host file so the clients could locate the servers on our network as a backup to DNS since our previous Network Monkey er ... Admin couldn't keep his DNS working properly. We also use it as simple tool to redirect users to our intranet when they try to visit webshots.com or various other garbage sites we used to have problems with. Most of the users don't know it's there and the few that do know how to modify it have to do it every time they log in if they want to visit those sites which are also blocked by the firewall as well, but the old netadmin sometimes couldn't keep that up either. The few users that know it's there don't visit the sites we redirect anyway.

We don't rely on it anymore but do keep it updated.

MojoZig
 
Come on Guys, this is a learning place, lets see some more actual scipts samples....

Phil Gordemer
ARH Associates...
 
Didn't you get the memo? Mine is used by nearly everybody. ;-)

I hope you find this post helpful.

Regards,

Mark
 
and that deserves a Martini??

**grin**

Phil Gordemer
 
Actually I am just commenting that a lot of people on this forum come here for help because they just don't know scripting and they use what they can find here. I've not seen a lot of variations over the past few years since I first started posting my script.

Let's not kid ourselves, there really is a base set of standards to a login script. Configure drives and printers and maybe set a few settings on the PC. The majority of customization should be done via GPO and not script.

Anything really beyond this and you are looking at specific needs for a company based on their environment.

I hope you find this post helpful.

Regards,

Mark
 
Thanks for a great post, I found much inspiration here.

My script (source below) is based on gordemer script, Dan Thomsons (his script can be found here: as well as my own additions.

This is my first try on a major logon script written in vbscript, so any input on my coding is welcome.

I would like to move the content of "Actions based on group membership(s)", "Actions based on Computer name" and "Actions based on user" out in their own xml file (not the content really, but the rules - is it clear what I mean?). If somebody could point me to a place where I can see some examples of how its done, or a tutorial, it would be great.

Anyways, here is the code. Please not that this is still a beta version.

Best regards,
Egil Hansen.

Code:
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Define Variables and Constants
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Dim objFileSys
Dim objIntExplorer
Dim objWshNetwork
Dim objWshShell
Dim strCurrentDirectory 'Directory from where the script is running
Dim strDomain           'Domain of the user
Dim strHomePage         'Homepage to be set for user
Dim strLogonPath        'Path to location from where the script is running
Dim strOSProdType       'OS Product type (WinNT, LanmanNT, ServerNT)
Dim strWorkstation      'Local Computer Name
Dim strUserGroups       'List of groups the user is a meber of
Dim intCounter          'General counter
Const UseNTServer = 0   'Sets whether this script runs when logging on locally
                        'to Windows Servers.
                        'Values are: 1 (Yes) OR 0 (No)

' year.month.day.hour
Version	= "2006.01.06.11"
bErrorDuringLogon = False
bUptoDate = False

'Initialize common scripting objects
Set objFileSys    = CreateObject( "Scripting.FileSystemObject" )
Set objWshNetwork = CreateObject( "WScript.Network" )
Set objWshShell   = CreateObject( "WScript.Shell" )

'Pause script until user is fully logged on (applies only to Win 9x or ME)
'This will timeout after 10 seconds
strUser = ""
intCounter = 0
Do
	strUserID = objWshNetwork.Username
	intCounter = intCounter + 1
	Wscript.Sleep 500
Loop Until strUserID <> "" OR intCounter > 20

'Check for error getting username
If strUserID = "" Then
	objWshShell.Popup "Logon script failed - Contact the IT Department.", , "Logon script", 48
	Call Cleanup
End If

'If it's the administrator logging on, don't run logon script.
If LCase(strUserID) = "administrator" Then
	Call Cleanup
End If

' Find the current directory
' It seems that "objWshShell.currentdirectory" is unsupported on Windows 2000,
' so the other (rather ugly) solution is the following (thanks to "conan3" from tek-tips.com's forums).
strCurrentDirectory = Left(Wscript.scriptfullname,Instr(1,WScript.ScriptFullName,wscript.scriptname,1)-1)

'Setup IE for use as a status message window
Call SetupIE

'Display welcome message
Call UserPromptBold ("Welcome " & strUserID)
Call UserPrompt ("Please wait while the logon script runs")
Call UserPrompt ("Logon script version: " & Version)
objIntExplorer.Document.WriteLn ("<ul>")

'Check registry to see last version run
RegKeyLP = "HKCU\Software\Company name\LogonScript\Version"
If KeyExists (RegKeyLP) Then
	If objWshShell.RegRead(RegKeyLP) = Version Then
		bUptoDate = True
	Else
		objWshShell.RegWrite RegKeyLP, Version,"REG_SZ"
	End If
Else
	objWshShell.RegWrite RegKeyLP, Version,"REG_SZ"
End If

'Gather some basic system info
Call UserPromptBullet ("Getting system info . . .")
Call GetSystemInfo

If Not IsTerminalServerSession Then
	'Exit if we are logging on locally to a server and the 
	'script is set to NOT run on servers
	IF UseNTServer = 0 AND (strOSProdType = "LanmanNT" OR strOSProdType = "ServerNT") Then
		objWshShell.Popup "Windows Server - Exiting Logon Script!", 10, _
		"Logon to " & strDomain, 16
		Call CleanUp
	End if
End If

'Get group memberships
Call UserPromptBullet ("Getting group memberships . . .")
strUserGroups = ""
Call GetLocalGroupMembership
Call GetGlobalGroupMembership

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Actions based on group membership(s)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Call UserPromptBullet ("Setting up computer based on group memberships . . .")
objIntExplorer.Document.WriteLn ("<ul>")

' Default (Domain Users)
If InGroup( "Domain Users" ) Then
End If

' Admins (Domain Admins)
If InGroup( "Domain Admins" ) Then
End If

' SomeGroup
If InGroup( "SomeGroup" ) Then
	Call RunProgramInBackground ("path to some program","Running some program")
	Call MapDrive ("X:", "server", "share")
	Call AddPrinter ("domain", "print server", "print share")
	Call SetDefaultPrinter ("\\print serve\print share")
End If

objIntExplorer.Document.WriteLn ("</ul>")

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Run Once section
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
If Not bUptoDate Then 
	Call UserPromptBullet ("Applying default settings . . .")
	objIntExplorer.Document.WriteLn ("<ul>")
	'Things to do go from here
	Call RenameMyComputer
	
	'... to here
	objIntExplorer.Document.WriteLn ("</ul>")
End If

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Actions based on Computer name
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Call UserPromptBullet ("Applying custom settings for computer:")
Select Case UCase (strWorkstation)
'Remember to write the computername in upper case, e.g.
'   Case "PCNAME"
'      Call UserPrompt ("PCNAME stuffs")
   Case Else
      Call UserPrompt ("No extra settings found")
End Select

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Actions based on user
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Call UserPromptBullet ("Applying custom settings for user:")
Select Case LCase (strUserID)
'Remember to write the username in lower case, e.g.
'   Case "bartsimpson.test"
'      Call UserPrompt ("dooooooh ")
   Case Else
      Call UserPrompt ("No extra settings found")
End Select

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' End section
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'Start SMSls.bat
'Do not run if a member of the Domain Administrators
'or in the global group DoNotInstallSMS
'If InGroup("Domain Admins") OR InGroup("DoNotInstallSMS") Then
'  Call UserPrompt ("Skipping SMSLS.BAT")
'Else
'  objWshShell.Run "%COMSPEC% /c " & strLogonPath & "\smsls.bat", 0, False
'End If

' Synchronize time with domain controller
Call UserPromptBullet ("Setting time and date")
objWshShell.Run "%COMSPEC% /c net time /domain:domain goes here /set /yes", 0, False

' End bullet.
objIntExplorer.Document.WriteLn ("</ul>")

'Close Internet Explorer
If bErrorDuringLogon Then
	Call UserPromptBold ("Error:")
	Call UserPromptRed ("There where one or more errors during logon, please contact the IT department, and give us the information in this window.") 
Else
	'Inform user that logon process is done
	Call UserPrompt ("Finished running logon script.")
	Call UserPrompt ("(closing window in 10 seconds)")
End If

'Write standard html end-tags
objIntExplorer.Document.WriteLn ("</div>")
objIntExplorer.Document.WriteLn ("</body>")
objIntExplorer.Document.WriteLn ("</html>")

' Only close status window if there was no errors during logon
If Not bErrorDuringLogon Then
	' Wait 10 secs
	Wscript.Sleep (10000)
	objIntExplorer.Quit()	
End If

Call Cleanup

''''''''''''''''''''''
' Subs and functions '
''''''''''''''''''''''

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Sub:      AddPrinter
' Purpose:  Connect to shared network printer
' Input:    strPrtServerDomain  Domain in which print server is a member
'           strPrtServer        Name of print server
'           strPrtShare         Share name of printer
' Usage:    Call AddPrinter ("Mydomain2", "MyPrtSvr2", "Bld1Rm101-HP4050")
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Sub AddPrinter(strPrtServerDomain, strPrtServer, strPrtShare)
	On Error Resume Next

	Dim strPrtPath    'Full path to printer share
	Dim objPrinter    'Object reference to printer
	Dim strMsg        'Message output to user
	Dim blnError      'True / False error condition

	blnError = False

	'Build path to printer share
	strPrtPath = "\\" & strPrtServer & "\" & strPrtShare

	'Test to see if shared printer exists.
	'Proceed if yes, set error condition msg if no.
	Set objPrinter = GetObject ("WinNT://" & strPrtServerDomain & "/" & strPrtServer & "/" & strPrtShare)
	If IsObject( objPrinter ) AND (objPrinter.Name <> "" AND objPrinter.Class = "PrintQueue") Then
		'Different mapping techniques depending on OS version
		If objWshShell.ExpandEnvironmentStrings( "%OS%" ) = "Windows_NT" Then
		Err.Clear
		'Map printer
		objWshNetwork.AddWindowsPrinterConnection strPrtPath
		Else
		'Mapping printers for Win9x & ME is a pain and unreliable.
		End If
	Else
		blnError = True
	End IF

	'Check error condition and output appropriate user message
	If Err <> 0 OR blnError Then
		Call UserPromptBulletRed ("Error: Unable to connect the network printer " & strPrtShare & " from server " & strPrtServer) 
		bErrorDuringLogon = true
	Else
		Call UserPromptBullet ("Successfully added printer connection to " & strPrtPath)
	End If

	Set objPrinter = Nothing
End Sub

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Sub:      SetDefaultPrinter
' Purpose:  Set the default printer
' Input:    strPrinterName = \\srv\printer
' Usage:    Call SetDefaultPrinter ("\\srv100f\sl01")
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Sub SetDefaultPrinter(strPrinterName)
	On Error Resume Next
	objWshNetwork.SetDefaultPrinter strPrinterName
	If Err.number = 0 Then
		Call UserPromptBullet ("Setting default printer to " & strPrinterName)
	Else
		Call UserPromptBulletRed ("Error: Unable to set the default printer to """ & strPrinterName & """")
		bErrorDuringLogon = true
	End If
	Err.Clear
End Sub

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Sub:      RunProgramInBackground
' Purpose:  Start at program in the background
' Input:    program = full path to program
'			message = message to print to screen
' Usage:    Call RunProgramInBackground ("c:\tmp.cmd","Running something...")
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Sub RunProgramInBackground(program,message)
	On Error Resume Next
	objWshShell.Run program, 0, false
	' If there was an error (finding the program ect.) print an error to the user.
	If Err.number = 0 Then
		Call UserPromptBullet (message)
	Else
		Call UserPromptBulletRed ("Error: Unable to run program """ & program & """")
		bErrorDuringLogon = true
	End If
	Err.Clear
End Sub


''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Sub:      MapDrive
' Purpose:  Map a drive to a shared folder
' Input:    strDrive    Drive letter to which share is mapped
'           strServer   Name of server that hosts the share
'           strShare    Share name
' Usage:    Call MapDrive ("X:", "StaffSvr1", "StaffShare1")
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Sub MapDrive( strDrive, strServer, strShare )
	On Error Resume Next

	Dim strPath       'Full path to printer share
	Dim blnError      'True / False error condition

	blnError = False

	'Disconnect Drive if drive letter is already mapped.
	'This assures everyone has the same drive mappings
	If objFileSys.DriveExists(strDrive) Then
		objWshNetwork.RemoveNetworkDrive strDrive, , True
	End If

	'Build path to share
	strPath = "\\" & strServer & "\" & strShare

	'Test to see if share exists. Proceed if yes, set error condition if no.
	' This can check non hidden shares, use if all shares are not hidden.
	' objFileSys.DriveExists(strPath) = True
	If IsAlive(strServer) Then
		Err.Clear
		objWshNetwork.MapNetworkDrive strDrive, strPath
	Else
		blnError = True
	End If

	'Check error condition and output appropriate user message
	If Err.Number <> 0 OR blnError Then
		Call UserPromptBulletRed ("Error: Unable to map " & strDrive & " to " & strShare & " on " & strServer) 
		bErrorDuringLogon = true
	Else
		Call UserPromptBullet ("Successfully added mapped drive connection to " & strPath)
	End If
End Sub

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Sub:      GetLocalGroupMembership
' Purpose:  Gather all local groups to which the current user belongs
' Output:   Local group names are added to strUserGroups
' Usage:    Call GetLocalGroupMembership
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Sub GetLocalGroupMembership
	On Error Resume Next

	Dim colGroups   'Collection of groups on the local system
	Dim objGroup    'Object reference to individual groups
	Dim objUser     'Object reference to individual group member

	'Verify system is not Windows 9x or ME
	If objWshShell.ExpandEnvironmentStrings( "%OS%" ) = "Windows_NT" Then
		'Connect to local system
		Set colGroups = GetObject( "WinNT://" & strWorkstation )
		colGroups.Filter = Array( "group" )
		'Process each group
		For Each objGroup In colGroups
		'Process each user in group
		For Each objUser in objGroup.Members
			'Check if current user belongs to group being processed
			If LCase( objUser.Name ) = LCase( strUserID ) Then
			'Add group name to list
			strUserGroups = strUserGroups & objGroup.Name & ","
			End If
		Next
		Next
		Set colGroups = Nothing
	End If
End Sub

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Sub:      GetGlobalGroupMembership
' Purpose:  Gather all global groups the current user belongs to
' Output:   Global group names are added to strUserGroups
' Usage:    Call GetGlobalGroupMembership
' Notes:    Use WinNT connection method to be backwards
'           compatible with NT 4 domains
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Sub GetGlobalGroupMembership
	On Error Resume Next

	Dim objNameSpace
	Dim objUser

	Const ADS_READONLY_SERVER = 4

	Set objNameSpace = GetObject( "WinNT:" )
	'Use the OpenDSObject method with the ADS_READONLY_SERVER
	'value to grab the "closest" domain controller

	'Connect to user object in the domain
	Set objUser = objNameSpace.OpenDSObject( _
		"WinNT://" & strDomain & "/" & strUserID, "", "", ADS_READONLY_SERVER)
	'Process each group
	For Each objGroup In objUser.Groups
		'Add group name to list
		strUserGroups = strUserGroups & objGroup.Name & ","
	Next
	Set objNameSpace = Nothing
End Sub

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Function: InGroup
' Purpose:  Determine if user belongs to specified group
' Input:    Name of group to test for membership
' Output:   True or False
' Usage:    If InGroup("Domain Admins") Then <do something>
' Requirements:
'           strUserGroups must have been previously populated via
'           GetLocalGroupMembership and/or GetGlobalGroupMembership
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Function InGroup(strGroup)
	On Error Resume Next

	InGroup = False
	'Search strUserGroups for strGroup
	If Instr( 1, LCase( strUserGroups ), LCase( strGroup ), 1) Then InGroup = True
End Function

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Sub:      GetSystemInfo
' Purpose:  Gather basic information about the local system
' Output:   strDomain, strOSProdType, strWorkstation, strLogonPath
' Usage:    Call GetSystemInfo
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Sub GetSystemInfo
	On Error Resume Next

	'Get domain name
	If objWshShell.ExpandEnvironmentStrings( "%OS%" ) = "Windows_NT" Then
		strDomain = objWshNetwork.UserDomain
	Else
		strDomain = objWshShell.RegRead( "HKLM\System\CurrentControlSet\" & "Services\MSNP32\NetWorkProvider\AuthenticatingAgent" )
	End If

	'Get Product Type from Registry (WinNT, LanmanNT, ServerNT)
	strOSProdType = objWshShell.RegRead("HKLM\System\CurrentControlSet\Control\ProductOptions\ProductType")

	'Get computer name
	If IsTerminalServerSession Then
		'Set strWorkstation to the real name and not the name of the server
		strWorkstation = objWshShell.ExpandEnvironmentStrings( "%CLIENTNAME%" )
	Else
		strWorkstation = objWshNetwork.ComputerName
	End If

	'Get the path to the location from where the script is running
	strLogonPath = Left( Wscript.ScriptFullName, ( InstrRev( Wscript.ScriptFullName, "\") -1))
End Sub

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Function: IsTerminalServer
' Purpose:  Determine if the script is running in a terminal server session
' Output:   True if running in a terminal server session
'           False if not running in a terminal server session
' Usage:    If IsTerminalServerSession = True Then <Do Something>
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Function IsTerminalServerSession
	On Error Resume Next
	Dim strName

	'Detect if this is a terminal server session
	'If it is, set some names to the terminal server client name
	strName = objWshShell.ExpandEnvironmentStrings( "%CLIENTNAME%" )
	If strName <> "%CLIENTNAME%" AND strName <> "" Then 
		IsTerminalServerSession = True
	End If

End Function
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Sub:      SetupIE
' Purpose:  Set up Internet Explorer for use as a status message window
' Usage:    Call SetupIE
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Sub SetupIE
	On Error Resume Next

	Dim strTitle    'Title of IE window
	Dim intCount    'Counter used during AppActivate

	strTitle = "Logon Script"

	'Create reference to objIntExplorer
	'This will be used for the user messages. Also set IE display attributes
	Set objIntExplorer = Wscript.CreateObject("InternetExplorer.Application")
	With objIntExplorer
		.Navigate "about:blank"
		.ToolBar   = 0
		.Menubar   = 0
		.StatusBar = 0
		.Width     = 600
		.Height    = 500
		.Left      = 20
		.Top       = 20
	End With

	'Set some formating
	With objIntExplorer.Document
		.WriteLn ("<!doctype html public>")
		.WriteLn   ("<head>")
		.WriteLn    ("<title>" & strTitle & "</title>")
		.WriteLn     ("<style type=""text/css"">")
		.WriteLn      ("body {border: 0; margin: 5; text-align: left; font-family: verdana; font-size: 9pt;}")
		.WriteLn     ("</style>")
		.WriteLn   ("</head>")
		.WriteLn   ("<body>")
		.WriteLn   ("<div style=""float: right;""><img src=""" & strCurrentDirectory & "\logo.gif"" /></div>")
		.WriteLn   ("<div style=""clear: left;"">")
	End With

	'Wait for IE to finish
	Do While (objIntExplorer.Busy)
		Wscript.Sleep 200
	Loop

	'Show IE
	objIntExplorer.Visible = 1

	'Make IE the active window
	For intCount = 1 To 100
		If objWshShell.AppActivate(strTitle) Then Exit For
		WScript.Sleep 50
	Next
End Sub

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Write strPrompt to IE display 
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Sub UserPrompt( strPrompt )
	On Error Resume Next
	objIntExplorer.Document.WriteLn (strPrompt & "<br />")
End Sub

Private Sub UserPromptBold( strPrompt )
	On Error Resume Next
	objIntExplorer.Document.WriteLn ("<strong>" & strPrompt & "</strong><br />")
End Sub

Private Sub UserPromptRed( strPrompt )
	On Error Resume Next
	objIntExplorer.Document.WriteLn ("<span style=""color: red;"">" & strPrompt & "</span><br />")
End Sub

Private Sub UserPromptBullet( strPrompt )
	On Error Resume Next
	objIntExplorer.Document.WriteLn ("<li>" & strPrompt & "</li>")
End Sub

Private Sub UserPromptBulletRed( strPrompt )
	On Error Resume Next
	objIntExplorer.Document.WriteLn ("<li style=""color: red;"">" & strPrompt & "</li>")
End Sub

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Test to see if Registry Key exists before acting on it
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function KeyExists (KeytoFind)
	Dim KeyTest
	Set objShell = CreateObject("WScript.Shell")
	On Error Resume Next
	KeyTest = objShell.RegRead (KeytoFind)
	If err <> 0 Then
		KeyExists = False
	Else
		KeyExists = True
	End If
	Set objShell = Nothing
End Function

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Test to see if host or url is alive through PING
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function IsAlive(strHost)
   Set objShell = CreateObject("WScript.Shell")
   IsAlive = Not CBool(objShell.run("ping -n 1 " & strHost,0,True))
   Set objShell = Nothing
End Function

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Rename My Computer to computer hostname
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub RenameMyComputer
   Const MY_COMPUTER = &H11&
   objComputerName = objWshNetwork.ComputerName
   Set objShell = CreateObject("Shell.Application")
   Set objFolder = objShell.Namespace(MY_COMPUTER)
   Set objFolderItem = objFolder.Self
   objFolderItem.Name = objComputerName
   Set objNetwork = Nothing
   Set objShell = Nothing
   Call UserPromptBullet ("Setting ""My Computer"" name to """ & objComputerName & """")
End Sub

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Sub:      Cleanup
' Purpose:  Release common objects and exit script
' Usage:    Call Cleanup
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub Cleanup
	On Error Resume Next

	Set objFileSys     = Nothing
	Set objWshNetwork  = Nothing
	Set objWshShell    = Nothing
	Set objIntExplorer = Nothing

	'Exit script
	Wscript.Quit( )
End Sub
 
mine is 3000 lines of code so it wont fit in the box ;-)
 
Yes I love logon scripts. Here's my version.
Code:
'==========================================================================
' NAME: LogonScript.vbs
'==========================================================================
'
' AUTHOR: Gene Magerr, Magerr Media
' DATE  : 11/25/2005
'
' COMMENT: This logon script will map printers, drives, create shortcuts
'          add favorites and do many other things based on groups users 
'          belong to
'
' Credits: Mark D. MacLachlan, Paul DeBrino, For the bulk of the script
'          Tek-Tips Forum, Hey scripting guy archive
'
'==========================================================================
'Option Explicit

'==========================================================================
' If testmode is set to true, a message will pop up telling the user
' the shortcuts to their desktops are being created
' this is a part of the addshortcuttodesktop sub
'==========================================================================
TestMode = True

'==========================================================================
' Create the Shell or environment for the commands:
'==========================================================================
Set WshShell = WScript.CreateObject("WScript.Shell")

'==========================================================================
' Define objects:
'==========================================================================
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set oDrives = WshNetwork.EnumNetworkDrives()

'==========================================================================
'Automatically find the domain name
'==========================================================================
Set objDomain = getObject("LDAP://rootDse")
strDomain = objDomain.Get("dnsHostName")

'==========================================================================
'Grab the user name
'==========================================================================
UserString = WshNetwork.UserName

'==========================================================================
'Bind to the user object to get user name and check for group memberships later
'==========================================================================
Set objUser = GetObject("WinNT://" & strDomain & "/" & UserString)

'==========================================================================
'Grab the computer name for use in add-on code later
'==========================================================================
strComputer = WshNetwork.ComputerName

'==========================================================================
'Set Trusted Sites for MGA Portal
'==========================================================================
Const HKEY_CURRENT_USER = &H80000001

Set objReg=GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Internet Settings\" _
    & "ZoneMap\Domains\mgae.com"

objReg.CreateKey HKEY_CURRENT_USER, strKeyPath

strValueName = "https"
dwValue = 2

objReg.SetDWORDValue HKEY_CURRENT_USER, strKeyPath, strValueName, dwValue

'==========================================================================        
' Map drives needed by all
'==========================================================================
Mapit "U", "\\netapp1\users", "", ""

'==========================================================================
'Now check for group memberships and map appropriate drives and printers
'==========================================================================
For Each objGroup In objUser.Groups
       	Select Case objGroup.Name
       
'==========================================================================        
' Domain Admins
'==========================================================================
       	Case "Domain Admins"
       	    Mapit "M", "\\misadmin\root", "", ""
            Mapit "N", "\\netapp1\MIS Archive", "", ""
            
            Call DesktopSC("LA_MIS", "\\netapp1\users\LA_MIS", "\\netapp1\users")
            Call DesktopSC("U-Drive", "\\netapp1\users", "")
			
            Call AddPrinter ("mgae", "rscprint", "misprint")
            Call AddPrinter ("mgae", "", "test")
            Call AddPrinter ("mgae", "rscprint", "sam")
            
            Call FavoritesSC ("-= LA MIS Team Site =-", "[URL unfurl="true"]https://portal.mgae.com/sites/mis")[/URL]
            
            WshNetwork.SetDefaultPrinter "\\rscprint\misprint"
    		strHomePage = "[URL unfurl="true"]https://portal.mgae.com/sites/mis"[/URL]
    		
'==========================================================================        
' LA_Test - Group for testing scripts and group policies
'==========================================================================    		
    	Case "LA_Test"
            Mapit "P", "\\mgashare1\Product Development", "", ""
			
			Call AddPrinter ("mgae", "rscprint", "pdclr")
								
    End Select
Next

'==========================================================================
'Set default homepage
'==========================================================================
If strHomePage <> "" Then
  Err.Clear
  WshShell.RegWrite "HKCU\Software\Microsoft\Internet Explorer\Main\Start Page", strHomePage
End If

'==========================================================================
'Configure the PC to show the Windows Version and Service Pack
'as an overlay to the desktop above the System Tray
'==========================================================================
'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

'==========================================================================
'Change My Computer Icon to the name of the computer
'==========================================================================
Const MY_COMPUTER = &H11&

Set objNetwork = CreateObject("Wscript.Network")
strComputer = objNetwork.ComputerName
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(MY_COMPUTER) 
Set objFolderItem = objFolder.Self
objFolderItem.Name = strComputer

'==========================================================================
'Change My Computer Icon from the name of the computer
'back to the default My Computer
'==========================================================================
'Const MY_COMPUTER = &H11&

'Set objShell = CreateObject("Shell.Application")
'Set objFolder = objShell.Namespace(MY_COMPUTER) 
'Set objFolderItem = objFolder.Self
'objFolderItem.Name = "My Computer"

'==========================================================================
'
' Sub:      AddPrinter
'
' Purpose:  Connect to shared network printer
'
' Input:
'           strPrtServerDomain  Domain in which print server is a member
'           strPrtServer        Name of print server
'           strPrtShare         Share name of printer
'
' Output:
'
' Usage:
'           Call AddPrinter ("Mydomain2", "MyPrtSvr2", "Bld1Rm101-HP4050")
'
'==========================================================================
Private Sub AddPrinter(strPrtServerDomain, strPrtServer, strPrtShare)

On Error Resume Next

  Dim strPrtPath    'Full path to printer share
  Dim objPrinter    'Object reference to printer
  Dim strMsg        'Message output to user
  Dim blnError      'True / False error condition

  blnError = False

'==========================================================================
'Build path to printer share
'==========================================================================
  strPrtPath = "\\" & strPrtServer & "\" & strPrtShare

'==========================================================================
'Test to see if shared printer exists.
'Proceed if yes, set error condition msg if no.
'==========================================================================
  Set objPrinter = GetObject("WinNT://" & strPrtServerDomain & "/" & strPrtServer & "/" & strPrtShare)
  If IsObject( objPrinter ) AND (objPrinter.Name <> "" AND objPrinter.Class = "PrintQueue") Then

'==========================================================================
'Different mapping techniques depending on OS version
'==========================================================================
     If WshShell.ExpandEnvironmentStrings( "%OS%" ) = "Windows_NT" Then
       Err.Clear
       
'==========================================================================       
'Map printer
'==========================================================================
       WshNetwork.AddWindowsPrinterConnection strPrtPath
     Else
     
'==========================================================================
'Mapping printers for Win9x & ME is a pain and unreliable.
'==========================================================================
     End If

  Else
    blnError = True
  End If

'==========================================================================
'Check error condition and output appropriate user message
'I modified this code to not show a Print Server in the
'error message if on did not exsist.
'==========================================================================
  If strPrtServer <> "" Then
  If Err <> 0 OR blnError = True Then
    strMsg = "Unable to connect to network printer. " & vbCrLf & _
             "Please contact MIS and ask them to check the " & vbCrLf & _
             "" & strPrtServer & " server." & _
             vbCrLf & "================================" & vbCrLf & _
             "Let them know that this message box appeared" & vbCrLf &_
             "and you are unable to connect to the '" _
             & strPrtShare & "' printer" & vbCrLf &_
             "Thank You "
    WScript.Echo strMsg 
  Else
    WScript.Echo ("Successfully added printer connection to " & strPrtPath)
  End If
  Else
  If Err <> 0 OR blnError = True Then
    strMsg = "Unable to connect to network printer. " & vbCrLf & _
    		 "Please contact MIS." & vbCrLf & _
             vbCrLf & "================================" & vbCrLf & _
             "Let them know that this message box appeared" & vbCrLf &_
             "and you are unable to connect to the '" _
             & strPrtShare & "' printer" & vbCrLf &_
             "Thank You "
    WScript.Echo strMsg 
  Else
    WScript.Echo ("Successfully added printer connection to " & strPrtPath)
  End If
End If
  Set objPrinter = Nothing

End Sub

'==========================================================================
'  Written in VBScript.
'  Paul DeBrino .:. [URL unfurl="true"]www.infinity-rd.com[/URL] .:. March 2004.
'  Establishes map drives.
'  Assign to OU Group Policy under USER CONFIG, WINDOWS SETTINGS, SCRIPTS, LOGON SCRIPT.
'
'  This script will: 
'  (1) check if the drive is already connected and, if so, disconnect it.
'  (2) map the drive.
'
'  Arguments are as follows: 
'     MAPIT  DRIVE-LETTER as string,  PATH as string, USER as string, PASSWORD as string
'     (1) Do not specify colon in drive letter.
'     (2) Do not end path with a forward slash.
'     (3) If user and password are not required to establish map, then specify a zero-length string as follows:  ""
'
' Reference Microsoft info at:
' [URL unfurl="true"]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/wsmthmapnetworkdrive.asp[/URL]
'==========================================================================

'==========================================================================
' Create the Shell or environment for the commands:
'==========================================================================
'Set oDrives = WshNetwork.EnumNetworkDrives()

'==========================================================================
' DEFINE WHO TO CONTACT for pop-up messages:
'==========================================================================
strContactMessage = "If you require assistance, please send an email to MIS Support."

'==========================================================================
' DO NOT MODIFY ANYTHING BELOW THIS POINT...
'   unless you are familiar with the proper settings.
'==========================================================================
Sub Mapit(strLetter, strPath, strUser, strPass)

'==========================================================================
' Define the DriveLetter:
'==========================================================================
Dim DriveLetter, RemotePath, bPopReminder, bForceRemoveFromProfile
Dim bRemoveFromProfile, bStoreInProfile, AlreadyConnected, i, objWSH


    DriveLetter = strLetter & ":"
'==========================================================================

'==========================================================================
' Define the remote path:
'==========================================================================
    RemotePath = strPath

'==========================================================================
' Pop-up Notices (set to False to disable notices, otherwise set to True):
'==========================================================================
    bPopReminder = True

'==========================================================================
' Define known errors to trap:
'==========================================================================
    Dim arrErrCode(1)
    Dim arrErrDesc(1)
    arrErrCode(0) = -2147023694
    arrErrCode(1) = -2147024811
    arrErrDesc(0) = "Unable to map drive " & DriveLetter & " to " & RemotePath _
        & " due to a previously defined remembered map with the same letter." _
        & vbCrLf & vbCrLf & "Please MANUALLY disconnect map drive " & DriveLetter _
        & ", then Log Out and Log back in."
    arrErrDesc(1) = "Unable to map drive " & DriveLetter & " to " & RemotePath _
        & " since " & DriveLetter & ": was previously reserved by your computer." _
        & vbCrLf & vbCrLf & "(Refer to Management, Shared Folders, Shares)"

'==========================================================================
' Define whether the map information should be removed from the current user's profile:
'==========================================================================
    bForceRemoveFromProfile = True
    bRemoveFromProfile = True

'==========================================================================
' Define whether the map information should be stored in the current user's profile:
'==========================================================================
    bStoreInProfile = False

'==========================================================================
' Check if already connected:
'==========================================================================
    AlreadyConnected = False
    For i = 0 To oDrives.Count - 1 Step 2
        If LCase(oDrives.Item(i)) = LCase(DriveLetter) Then AlreadyConnected = True
    Next

'==========================================================================
' Attempt to map the drive.  If already mapped, first attempt disconnect:
'==========================================================================
    If AlreadyConnected = True then
        WshNetwork.RemoveNetworkDrive DriveLetter, bForceRemoveFromProfile, bRemoveFromProfile
        If Not strUser = "" Then
            WshNetwork.MapNetworkDrive DriveLetter, RemotePath, bStoreInProfile, strUser, strPass
        Else
            WshNetwork.MapNetworkDrive DriveLetter, RemotePath, bStoreInProfile
        End If
        If bPopReminder = True Then WshShell.PopUp "Drive " & DriveLetter & " disconnected, then connected successfully to " & RemotePath
    Else
        On Error Resume Next
        If Not strUser = "" Then
            WshNetwork.MapNetworkDrive DriveLetter, RemotePath, bStoreInProfile, strUser, strPass
        Else
            WshNetwork.MapNetworkDrive DriveLetter, RemotePath, bStoreInProfile
        End If
        If Err.Number <> 0 Then
            bKnownError = False
            For I = LBound(arrErrCode) To UBound(arrErrCode)
                If Err.Number = arrErrCode(I) Then
                    bKnownError = True
                    strPopMessage = arrErrDesc(I)
                    ' Display the Disconnect Network Drives window:
                    If Err.Number = arrErrCode(0) Then
                        Set objWSH = Wscript.CreateObject("WScript.Shell")
                        objWSH.Run "rundll32.exe shell32.dll,SHHelpShortcuts_RunDLL Disconnect", 1, true
                    End If
                    Exit For
                End If
            Next
            If Not bKnownError Then

strPopMessage = "Unable to map drive " & DriveLetter & " to " & RemotePath _
                    
            End If
            
'==========================================================================
' Display warning message:
'==========================================================================
            strPopMessage = "WARNING!!   WARNING!!   WARNING!!   WARNING!!" _
            & VbCrLf &"================================"_
            & vbCrLf & VbCrLf & strPopMessage & vbCrLf & VbCrLf & strContactMessage
            WshShell.PopUp strPopMessage
            
        Else
            If bPopReminder = True Then WshShell.PopUp "Drive " & DriveLetter & " connected successfully to " & RemotePath
        End If
    End If

'==========================================================================
' Release resources:
'==========================================================================
    Set objWSH = Nothing

'==========================================================================
' Slight pause to ensure each pass has time to commit:
'==========================================================================
    wscript.sleep 200
End Sub

'==========================================================================
'Useage
'Call DesktopSC ("Test", "C:\Documents and Settings", "C:\Documents and Settings")
'==========================================================================
Sub DesktopSC (strName, strPath, strDir)

	If TestMode = True Then
      wscript.echo "=========== Desktop Shortcut ==========" & vbCrLf &_
      "Adding Short Cut  : " & strName &   ".lnk To the desktop"
      'wscript.echo "Target Path       : " & tpath
      'wscript.echo "Working Directory : " & tdir
    End If
	
	'Set WshShell = WScript.CreateObject("WScript.Shell")
	strDesktop = WshShell.SpecialFolders("Desktop")
	Set oShellLink = WshShell.CreateShortcut(strDesktop & "\" & strName & ".lnk")
	oShellLink.TargetPath = strPath
	oShellLink.WindowStyle = 1
	'oShellLink.Hotkey = "CTRL+SHIFT+F"
	'oShellLink.IconLocation = "C:\Program Files\Microsoft Office\OFFICE11\EXCEL.EXE, 0"
	oShellLink.Description = strName & "Shortcut"
	oShellLink.WorkingDirectory = strDir
	oShellLink.Save

End Sub

'==========================================================================
'Useage
'Call FavoritesSC ("-= Name for shortcut =-", "[URL unfurl="true"]http://www.whereever.com")[/URL]
'==========================================================================
Sub FavoritesSC (strName, strPath)

	strFavorites = WSHShell.SpecialFolders("Favorites")
	strPath = "[URL unfurl="true"]https://portal.mgae.com/sites/mis"[/URL]
	Set objShortcut = WSHShell.CreateShortcut(strFavorites & "\" & strName & ".lnk")
	objShortcut.TargetPath = strPath
	objShortcut.Save
	
End Sub

'==========================================================================
'Add On Code goes above this line
'==========================================================================

'==========================================================================
'Clean Up Memory We Used
'==========================================================================
Set oDrives = Nothing
Set objUser = Nothing
Set objGroup = Nothing
Set WshNetwork = Nothing
Set strDomain = Nothing
Set WshShell = Nothing
Set WshPrinters = Nothing
Set oShellLink = Nothing
  
'==========================================================================
'Quit the Script
'==========================================================================
wscript.quit
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top