Hi all, I've been writing a login script which checks for whether a user is in a group or not, and if that user is in the group then it copies some files. It works OK, provided the group specified in ftnIsGroup exists, otherwise it bails out and shows "Windows Script Host Script: LoginScript.VBS Line: 119 Char: 2 Error: The group name could not be found Code: 800708AC Source: (null)" If I have "On Error Resume Next" in the code, it bails out of the function, and doesn't return any set values. Does anyone know how to stop it from doing it? Here follows the code... thanks in advance anyone! --- LOGIN SCRIPT.VBS --- Public objShell, objFSO, objNetwork Public strDFSMenu, strHDDProfile, strHDDMenu, strHDDPrograms, strHDDStartup Public objFolder, objFiles, objFile Public strSourcePath, strDestinationPath, objSrcFolder, objSrcFiles Public intValidGroup, objGroup, objUser Public objActiveDirectory, strLdapPath, strLdapSplit, intValidOU, strLdap, intLoopVal, arrLdapItem Set objShell = CreateObject("WScript.Shell") Set objFSO = CreateObject("Scripting.FileSystemObject") Set objNetwork = CreateObject("WScript.Network") strDFSMenu = "\\Server.Local\Root1DFS\StartMenus\Revised <\\Server.Local\Root1DFS\StartMenus\Revised> " strHDDProfile = "C:\Documents And Settings\" & objNetwork.UserName strHDDMenu = strHDDProfile & "\Start Menu" strHDDPrograms = strHDDMenu & "\Programs" strHDDStartup = strHDDPrograms & "\Startup" Set objFolder = objFSO.GetFolder(strHDDMenu) Set objFiles = objFolder.Files If objFiles.Count > 0 then For Each objFile In objFiles objFile.Delete Next End If If objFSO.FolderExists(strHDDPrograms) Then objFSO.DeleteFolder strHDDPrograms, true End If objFSO.CreateFolder(strHDDPrograms) objFSO.CreateFolder(strHDDStartup) If ftnIsGroup("ExistantGroup","") Then Call subLoadMenu("PathToFiles","Destination") If ftnIsOU("England") Then Call ftnClearAllDrives(FALSE) Call ftnMapDrive("W:","\\SERVER.LOCAL\Workgroups$") End If End If If ftnIsGroup("NonExistantGroup","") Then wscript.echo "You should never see this!" End If ' ############################################################################ ## ' # Function to clear all network drives ' # Author: Jon Spriggs ' # Date 22/11/04 ' # Use: If ftnClearAllDrives() Then wscript.echo "All Drives Cleared" ' ############################################################################ ## Function ftnClearAllDrives(tofIncHome) ftnClearAllDrives = TRUE intMapped = 0 Set objDrives = objNetwork.EnumNetworkDrives For i = 0 to objDrives.Count - 1 Step 2 If objDrives.Item(i) = "H:" AND tofIncHome=FALSE Then ' We can't remove this drive - it's the home drive Else objNetwork.RemoveNetworkDrive objDrives.Item(i), TRUE, TRUE Set objPostDrives = objNetwork.EnumNetworkDrives For j = 0 to objPostDrives.Count - 1 Step 2 If objPostDrives.Item(j) = objDrives.Item(i) Then intMapped = 1 Next End If Next If intMapped = 0 Then ftnClearAllDrives = TRUE If intMapped = 1 Then ftnClearAllDrives = FALSE End Function ' ############################################################################ ## ' # Function to remove a network drive ' # Author: Jon Spriggs ' # Date 22/11/04 ' # Use: If ftnRemoveDrive("X:") Then wscript.echo "Drive Cleared" ' # If ftnRemoveDrive("\\Server\Share") Then wscript.echo "Share Cleared" ' ############################################################################ ## Function ftnRemoveDrive(strDrive) ftnRemoveDrive = TRUE intMapped = 0 objNetwork.RemoveDrive strDrive, TRUE, TRUE set objDrives = objNetwork.EnumNetworkDrives for i = 0 to objDrives.Count - 1 If objDrives.Item(i) = strDrive Then intMapped = 1 Next If intMapped = 1 Then ftnRemoveDrive = TRUE If intMapped = 0 Then ftnRemoveDrive = FALSE End Function ' ############################################################################ ## ' # Function to map a network drive ' # Author: Jon Spriggs ' # Date 22/11/04 ' # Use: If ftnMapDrive("X:","\\Server\Share") Then wscript.echo "Drive Mapped" ' ############################################################################ ## Function ftnMapDrive(strDrive,strShare) ftnMapDrive = TRUE intMapped = 0 objNetwork.MapNetworkDrive strDrive,strShare set objDrives = objNetwork.EnumNetworkDrives for i = 0 to objDrives.Count - 1 Step 2 If objDrives.Item(i) = strDrive Then intMapped = 1 Next If intMapped = 1 Then ftnMapDrive = TRUE If intMapped = 0 Then ftnMapDrive = FALSE End Function ' ############################################################################ ## ' # Subroutine to copy files from strSource to strDestination ' # Author: Jon Spriggs ' # Date 17/11/04 ' # Use: Call subLoadMenu("Source","Destination") ' ############################################################################ ## Public Sub subLoadMenu(strSource,strDestination) strSourcePath = strDFSMenu & "\" &strSource strDestinationPath = strHDDPrograms & "\" & strDestination Set objSrcFolder = objFSO.GetFolder(strSourcePath) Set objSrcFiles = objSrcFolder.Files If objSrcFiles.Count <> 0 Then If Not objFSO.FolderExists(strDestinationPath) Then objFSO.CreateFolder(strDestinationPath) End If objFSO.CopyFile strSourcePath & "\*.*", strDestinationPath End If End Sub ' ############################################################################ ## ' # Common function to determine group membership ' # Author: Jon Spriggs ' # Date 17/11/04 ' # Use: If ftnIsGroup("ABC") THEN wscript.echo "In group ABC" ' ############################################################################ ## Function ftnIsGroup(strGroup,strDomain) intValidGroup = 0 ftnIsGroup = FALSE Err.Clear Set objGroup = GetObject("WinNT://" & objNetwork.UserDomain & "/" & strGroup & ",group") If Err<>0 Then ftnIsGroup = FALSE Else If objGroup.Count > 0 Then For Each objUser in objGroup.Members If objUser.Name = objNetwork.UserName Then intValidGroup = 1 Next Else intValidGroup = 0 End If End If If intValidGroup = 1 Then ftnIsGroup = TRUE Else ftnIsGroup = FALSE End If End Function ' ############################################################################ ## ' # Common function to determine Presence of User in OU ' # Author: Jon Spriggs ' # Date 17/11/04 ' # Use: If ftnIsOU("ABC") Then wscript.echo "In OU ABC" ' ############################################################################ ## Function ftnIsOU(strOU) Set objActiveDirectory = CreateObject("ADSystemInfo") strLdapPath = objActiveDirectory.UserName arrLdapSplit = split(strLdapPath,",") intValidOU = 0 strLdap = "Entering" For intLoopVal = LBound(arrLdapSplit) To UBound(arrLdapSplit) arrLdapItem = split(arrLdapSplit(intLoopVal),"=") strLdap = arrLdapItem(1) If strLdap = strOU Then intValidOU = 1 Next If intValidOU = 1 Then ftnIsOU = TRUE Else ftnIsOU = FALSE End If End Function