That code works it just doesent work the way i need it to. here is my code so you can see what i have. as of right now i have IE opening each time that a drive is being mapped and i am trying to get it so that IE only opens once.
Code:
Option Explicit
const pcstrPath = ";G:\SYSINFO;F:\Public"
const pcstrC3Server = "\\Z02DBCVSC01\"
dim OIE,Time_out,Title,Button
set oIE = CreateObject("InternetExplorer.Application")
Modeless oIE, "VSC Logon Script is running, please wait..."
Dim pstrUserName,pstrGroups,pstrFailed,pstrSpecialVolChar
Modeless oIE, "VSC Logon Script is running, please wait...</p></p> getting User Name"
pstrUserName = fstrGetUserProperty("samAccountName")
Modeless oIE, "VSC Logon Script is running, please wait...</p></p> getting group membership"
pstrGroups = ucase(fstrGetUserProperty("MemberOf"))
if InStr(pstrGroups, "VSC C3 SERVICE ACCOUNTS") then
pstrSpecialVolChar = "Z"
end if
If fblnMapDriveAndFolder("I:", "\\Z02APPVSC01\User Share", "\" & pstrUserName) = False Then
pstrFailed = pstrFailed & "</p>" & "I:" & "\\Z02APPVSC01\User Share\" & pstrUserName & "\ Has NOT been mapped"
End If
Modeless oIE, "VSC Logon Script is running, please wait...</p></p>Mapping " & "G:" & pcstrC3Server & pstrSpecialVolChar & "RAFACSII$\"
If fblnMapDriveAndFolder("G:", pcstrC3Server & pstrSpecialVolChar & "RAFACSII$", "") = False Then
pstrFailed = pstrFailed & "</p>" & "G:" & pcstrC3Server & pstrSpecialVolChar & "RAFACSII$\ Has NOT been mapped"
End If
Modeless oIE, "VSC Logon Script is running, please wait...</p></p>Mapping " & "H:" & pcstrC3Server & pstrSpecialVolChar & "RAFACS$\"
If fblnMapDriveAndFolder("H:", pcstrC3Server & pstrSpecialVolChar & "RAFACS$", "") = False Then
pstrFailed = pstrFailed & "</p>" & "H:" & pcstrC3Server & pstrSpecialVolChar & "RAFACS$\ Has NOT been mapped"
End If
if InStr(pstrGroups, "VSC USERS - CIS") then
Modeless oIE, "VSC Logon Script is running, please wait...</p></p>Mapping " & "J:\\Z02RSCVSC04\NOVAShare\MIS\LOCAL"
If fblnMapDriveAndFolder("J:", "\\Z02RSCVSC04\NOVAShare\MIS\LOCAL", "") = False Then
pstrFailed = pstrFailed & "</p>" & "J:" & "\\Z02RSCVSC04\NOVAShare\MIS\LOCAL Has NOT been mapped"
End If
end if
Modeless oIE, "VSC Logon Script is running, please wait...</p></p>Mapping " & "K:\\Z02APPVSC01\PUBARC\"
If fblnMapDriveAndFolder("K:", "\\Z02APPVSC01\PUBARC", "") = False Then
pstrFailed = pstrFailed & "</p>" & "K:" & "\\Z02APPVSC01\PUBARC\ Has NOT been mapped"
End If
if InStr(pstrGroups, "VSC USERS - CIS") then
Modeless oIE, "VSC Logon Script is running, please wait...</p></p>Mapping " & "L:\\Z02RSCVSC04\APPLShare\"
If fblnMapDriveAndFolder("L:", "\\Z02RSCVSC04\APPLShare\", "") = False Then
pstrFailed = pstrFailed & "</p>" & "L:" & "\\Z02RSCVSC04\APPLShare\ Has NOT been mapped"
End If
end if
' if InStr(pstrGroups, "VSC C3 Service Accounts") then
' Modeless oIE, "VSC Logon Script is running, please wait...</p></p>Mapping " & "L:\\Z02RSCVSC04\APPLShare\"
' If fblnMapDriveAndFolder("L:", "\\Z02RSCVSC04\APPLShare\", "") = False Then
' pstrFailed = pstrFailed & "</p>" & "L:" & "\\Z02RSCVSC04\APPLShare\ Has NOT been mapped"
' End If
' end if
Modeless oIE, "VSC Logon Script is running, please wait...</p></p>Mapping " & "M:" & pcstrC3Server & pstrSpecialVolChar & "IMROOT$\"
If fblnMapDriveAndFolder("M:", pcstrC3Server & pstrSpecialVolChar & "IMROOT$", "") = False Then
pstrFailed = pstrFailed & "</p>" & "M:" & pcstrC3Server & pstrSpecialVolChar & "IMROOT$\ Has NOT been mapped"
End If
'
'Sets up mappings for Supervisory share - \\Z02RSCVSC04\MGMTShare - Added by Rene 12/19/2006
'
if InStr(pstrGroups, "VSC _ADJUDICATIONS_MGMT_ZEN - CIS") then
Modeless oIE, "VSC Logon Script is running, please wait...</p></p>Mapping " & "N:\\Z02RSCVSC04\SUPVShare\"
If fblnMapDriveAndFolder("N:", "\\Z02RSCVSC04\SUPVShare", "") = False Then
pstrFailed = pstrFailed & "</p>" & "N:" & "\\Z02RSCVSC04\SUPVShare\ Has NOT been mapped"
End If
end if
if InStr(pstrGroups, "VSC _SIIO_ZEN - CIS") then
Modeless oIE, "VSC Logon Script is running, please wait...</p></p>Mapping " & "N:\\Z02RSCVSC04\SUPVShare\"
If fblnMapDriveAndFolder("N:", "\\Z02RSCVSC04\SUPVShare", "") = False Then
pstrFailed = pstrFailed & "</p>" & "N:" & "\\Z02RSCVSC04\SUPVShare\ Has NOT been mapped"
End If
end if
if InStr(pstrGroups, "VSC _N_DRIVE - CIS") then
Modeless oIE, "VSC Logon Script is running, please wait...</p></p>Mapping " & "N:\\Z02RSCVSC04\SUPVShare\"
If fblnMapDriveAndFolder("N:", "\\Z02RSCVSC04\SUPVShare", "") = False Then
pstrFailed = pstrFailed & "</p>" & "N:" & "\\Z02RSCVSC04\SUPVShare\ Has NOT been mapped"
End If
end if
'
'End of Supervisory share mappings
'
Modeless oIE, "VSC Logon Script is running, please wait...</p></p>Mapping " & "Checking to see if using Citrix"
if fblnCitrix = false then
Modeless oIE, "VSC Logon Script is running, please wait...</p></p>Mapping P:\\Z02C4CVSC01\DocProd"
If fblnMapDriveAndFolder("P:", "\\Z02C4CVSC01\DocProd", "") = False Then
pstrFailed = pstrFailed & "</p>" & "P:\\Z02C4CVSC01\DocProd Has NOT been mapped"
End If
end if
Modeless oIE, "VSC Logon Script is running, please wait...</p></p>Setting the PATH variable"
if fblnSetUserEnvVar("PATH",pcstrPath,True) = false then
pstrFailed = pstrFailed & "</p>" & "Could not set the Path environment variable to: " & "</p>" & pcstrPath
end if
if pstrFailed <> "" then
Modeless oIE, " The following Errors Occured:" & pstrFailed
call pause(10) 'pause for 5 seconds
end if
'Close the Splash Screen
oIE.quit
'Determines whether is the drive is already mapped
' If it is mapped to the wrong location this function will map it to
' the correct one
' else if drive doesn't exist then
' map it
' Yuppers Get 'R Done
Function fblnMapDriveAndFolder(strDriveLetter,strServerName, strPath)
On Error resume next
fblnMapDriveAndFolder = True
Dim pobjFsys
Set pobjFsys = CreateObject("Scripting.FileSystemObject")
'correction for wrong slash
strServerName = Replace(strServerName, "/", "\")
strPath = Replace(strPath, "/", "\")
'Below will put a "\\" on the front of the server name if it doesn't exist
If Left(strServerName, 2) <> "\\" Then
strServerName = "\\" & strServerName
End If
'Below will put take the "\" off of the end of the server name if it exists
If Right(strServerName, 1) = "\" Then
strServerName = Left(strServerName, Len(strServerName) - 1)
End If
'Below will put a "\" on the front of the path name if it doesn't exist
If Left(strPath, 1) <> "\" And strPath <> "" Then
strPath = "\" & strPath
End If
'Below will put a ":" on the end of the strDriveLetter if it doesn't exist
If Right(strDriveLetter, 1) <> ":" Then
strDriveLetter = Left(strDriveLetter, 1) & ":"
End If
If pobjFsys.FolderExists(strServerName & strPath) = False Then
'Create the folder because it doesn't exist
pobjFsys.CreateFolder strServerName & strPath & "\"
End If
'Check to see if the drive is already mapped
If pobjFsys.DriveExists(strDriveLetter) = True Then
'Check to see if the drive letter is mapped to the correct folder
If pobjFsys.FolderExists(strDriveLetter & strPath) = False Or strPath = "" Then 'The drive is mapped to the wrong location
'Map over the existing drive with the correct path
If fblnMapDrive(strDriveLetter, strServerName, strPath, True) = False Then
fblnMapDriveAndFolder = false
End If
End If
Else 'The drive doesn't exist
'Map the drive
If fblnMapDrive(strDriveLetter, strServerName, strPath, False) = False Then
fblnMapDriveAndFolder = false
End If
End If
Set pobjFsys = Nothing
If Err.Number <> 0 Then
err.clear
fblnMapDriveAndFolder = False
End If
End Function
Function fblnMapDrive(strDriveLetter, strServer, strFolderPath, blnRemoveFirst)' As Boolean
On Error resume next
fblnMapDrive = True
Dim objNetwork
' Purpose of script to create a network object. (objNetwork)
' Then to apply the MapNetworkDrive method.
Set objNetwork = CreateObject("WScript.Network")
If blnRemoveFirst = True Then
objNetwork.RemoveNetworkDrive strDriveLetter, True, True
End If
objNetwork.MapNetworkDrive strDriveLetter, strServer & strFolderPath, True
If Err.Number <> 0 Then
fblnMapDrive = False
End If
End Function
function fblnSetUserEnvVar(strVariable, strValue, blnConcat)
on Error resume next
dim wshShell, pobjEnv
fblnSetUserEnvVar = true
set WshShell = CreateObject("WScript.Shell")
Set pobjEnv = WshShell.Environment("User")
if blnConcat = true then
pobjEnv(strVariable) = pobjEnv(strVariable) & strValue
else
pobjEnv(strVariable) = strValue
end if
if err.number <> 0 then
fblnSetUserEnvVar = false
err.clear
end if
end function
Function fblnCitrix()
Dim strComputer
Dim objWMIService
Dim clSettings
Dim objRecord
fblnCitrix = true
on error resume next
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set clSettings = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
fblnCitrix = false
For Each objRecord In clSettings
if objRecord.WindowsDirectory <> "" then
if left(objRecord.WindowsDirectory,2) = "P:" then
fblnCitrix = true
exit for
end if
end if
Next
if err.number <> 0 then
msgbox err.description, "fblnCitrix",vbcritical
end if
Set objWMIService = Nothing
Set clSettings = Nothing
End Function
'This function will return the specified property
Function fstrGetUserProperty(strProperty)
On Error resume next
Dim pstrConnect, pstrVal
Dim pobjUser 'As ActiveDs.IADsUser
pstrConnect = fstrADSpath
Set pobjUser = GetObject(pstrConnect)
pstrVal = pobjUser.Get(strProperty)
if isArray(pstrVal) = true then
fstrGetUserProperty = join(pstrVal)
else
fstrGetUserProperty = pstrVal
end if
If Err.Number <> 0 Then
MsgBox Err.Description, vbCritical
End If
Set pobjUser = Nothing
End Function
'Gets the local Active Directory information
' Used to obtain the string to connect the user's AD object
Function fstrADSpath() 'As String
Dim pobjAdSysInfo 'As ActiveDs.ADSystemInfo
'Set pobjAdSysInfo = New ActiveDs.ADSystemInfo
Set pobjAdSysInfo = CreateObject("AdSystemInfo")
fstrADSpath = "LDAP://" & pobjAdSysInfo.UserName
Set pobjAdSysInfo = Nothing
End Function
function fblnSetUserEnvVar(strVariable, strValue, blnConcat)
on Error resume next
dim wshShell, pobjEnv
fblnSetUserEnvVar = true
set WshShell = CreateObject("WScript.Shell")
Set pobjEnv = WshShell.Environment("User")
if blnConcat = true then
if instr(1,ucase(pobjEnv(strVariable)),ucase(strValue)) <= 0 then
pobjEnv(strVariable) = pobjEnv(strVariable) & strValue
end if
else
pobjEnv(strVariable) = strValue
end if
if err.number <> 0 then
fblnSetUserEnvVar = false
err.clear
end if
end function