I swear I've seen this posted here before, but I can't seem to find it.
I have this script, and it all appears to work fine. What I'd like to do is use some IF statements for the printers. If they are not installed, install them. If they are installed, ignore them. How can that be done?
Is there a way to do the same with the mapped drives?
Pat Richard, MCSE MCSA:Messaging CNA
Microsoft Exchange MVP
Want to know how email works? Read for yourself -
I have this script, and it all appears to work fine. What I'd like to do is use some IF statements for the printers. If they are not installed, install them. If they are installed, ignore them. How can that be done?
Is there a way to do the same with the mapped drives?
Code:
'**********************************************************************************
' Set Environment Variables
'*********************************************************************************
Set WSHNetwork = WScript.CreateObject("WScript.Network")
Set WSHShell = WScript.CreateObject("WScript.Shell")
On Error Resume Next
Domain = WSHNetwork.UserDomain
UserName = ""
While UserName = ""
UserName = WSHNetwork.UserName
MyGroups = GetGroups(Domain, UserName)
Wend
'*********************************************************************************
'Function: GetGroups
'*********************************************************************************
Function GetGroups(Domain, UserName)
Set objUser = GetObject("WinNT://" & Domain & "/" & UserName)
GetGroups=""
For Each objGroup In objUser.Groups
GetGroups=GetGroups & "[" & UCase(objGroup.Name) & "]"
Next
End Function
'********************************************************************************
'Function: InGroup
'********************************************************************************
Function InGroup(strGroup)
InGroup=False
If InStr(MyGroups,"[" & UCase(strGroup) & "]") Then
InGroup=True
End If
End Function
'********************************************************************************
'Map Drives:
'********************************************************************************
WSHNetwork.RemoveNetworkDrive "i:", True, True
WSHNetwork.RemoveNetworkDrive "j:", True, True
WSHNetwork.RemoveNetworkDrive "l:", True, True
WSHNetwork.RemoveNetworkDrive "p:", True, True
WSHNetwork.RemoveNetworkDrive "q:", True, True
WSHNetwork.RemoveNetworkDrive "r:", True, True
WSHNetwork.RemoveNetworkDrive "s:", True, True
WSHNetwork.MapNetworkDrive "i:", "\\velvet\infoctr"
WSHNetwork.MapNetworkDrive "j:", "\\velvet\reference"
WSHNetwork.MapNetworkDrive "l:", "\\clio\images"
WSHNetwork.MapNetworkDrive "p:", "\\velvet\projects"
WSHNetwork.MapNetworkDrive "q:", "\\survey\www"
WSHNetwork.MapNetworkDrive "r:", "\\survey\databases"
WSHNetwork.MapNetworkDrive "s:", "\\velvet\shared"
if ingroup ("netadmin") then
WSHNetwork.MapNetworkDrive "u:", "\\clio\netadmin"
end if
'********************************************************************************
'Map Printers:
'********************************************************************************
WshNetwork.RemovePrinterConnection "\\journey\color"
WshNetwork.RemovePrinterConnection "\\journey\colorduplex"
WshNetwork.RemovePrinterConnection "\\journey\production"
WshNetwork.RemovePrinterConnection "\\journey\productionduplex"
WshNetwork.RemovePrinterConnection "\\journey\upstairs"
WshNetwork.RemovePrinterConnection "\\journey\upstairsduplex"
WshNetwork.RemovePrinterConnection "\\journey\downstairs"
WshNetwork.RemovePrinterConnection "\\journey\downstairsduplex"
WSHNetwork.AddWindowsPrinterConnection "\\velvet\color"
WSHNetwork.AddWindowsPrinterConnection "\\velvet\colorduplex"
WSHNetwork.AddWindowsPrinterConnection "\\velvet\production"
WSHNetwork.AddWindowsPrinterConnection "\\velvet\productionduplex"
WSHNetwork.AddWindowsPrinterConnection "\\velvet\upstairs"
WSHNetwork.AddWindowsPrinterConnection "\\velvet\upstairsduplex"
WSHNetwork.AddWindowsPrinterConnection "\\velvet\downstairscopier"
WSHNetwork.AddWindowsPrinterConnection "\\velvet\downstairscopierduplex"
WSHNetwork.AddWindowsPrinterConnection "\\velvet\upstairscopier"
WSHNetwork.AddWindowsPrinterConnection "\\velvet\upstairscopierduplex"
If INGROUP ("2North") Then
WSHNetwork.SetDefaultPrinter "\\velvet\upstairs"
End If
If INGROUP ("2South") Then
WSHNetwork.SetDefaultPrinter "\\velvet\productionduplex"
End If
If INGROUP ("1st") Then
WSHNetwork.SetDefaultPrinter "\\velvet\downstairscopierduplex"
End If
Pat Richard, MCSE MCSA:Messaging CNA
Microsoft Exchange MVP
Want to know how email works? Read for yourself -