View Single Post
Old 06-27-2008   #3 (permalink)
ekkehard.horner


 
 

Re: Help with Logon script error

Mike Bailey schrieb:
Quote:

> Below is a logon script that I've basically put together from various
> other examples. The intention of the script is to map a set of common
> drives for my users. The script should check to see if a drive mapping
> already exist, if so, then remove it, then map the drive letter back to
> what I want. I kow/think that part of it is an attempt to handle
> persistent drive letters in Explorer where even after disconnecting the
> drive,it still appears in "My Computer"
>
> When I run the script I get the following error:
>
> Line: 11
> Char: 1
> Error: object required 'objFSO'
>
> Can anyone help? I'm sure this is soemthing simple, but I have basically
> no VBS knowlege
>
> Thanks,
> Mike
>
>
> Here is the scrip:
>
> =====================================================================================
>
> Dim WshNet
Dim objFSO : Set objFSO = CreateObject( "Scripting.FileSystemObject" )
' now we have the required object
Quote:

>
> '*****************
> 'MAP COMMON DRIVES
> '*****************
> '
> 'Note: U: (User Home directory) is mapped in the user profile in Active
> Directory
>
> 'G: Drive - FS01\App
> '************************
> If (objFSO.DriveExists("G:" = True)) Then
==>
If objFSO.DriveExists( "G:" ) Then

Trying to be extra explicit (comparing a truth value to True, adding
brackets/parentheses) may make things worse by cluttering up the
code. Sending the result of the comparison between "G:" and True
to the .DriveExists method surely wasn't intended.

Quote:

> objNetwork.RemoveNetworkDrive "G:",True,True
> End If
>
> If objFSO.DriveExists("G:") Then
' this is good style
Quote:

> Set objReg =
> GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
>
> objReg.DeleteKey HKCU, "Network\" & Left("G:", 1)
> Set objReg = Nothing
> End If
>
> Set WshNet = WScript.CreateObject("WScript.Network")
> WshNet.MapNetworkDrive "G:", "\\fs01\app"
> Set WSHNet = Nothing
>
> 'S: Drive - Bea2\Users
> '************************
> If (objFSO.DriveExists("S:" = True)) Then
> objNetwork.RemoveNetworkDrive "S:",True,True
> End If
>
> If objFSO.DriveExists("S:") Then
> Set objReg =
> GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
>
> objReg.DeleteKey HKCU, "Network\" & Left("S:", 1)
> Set objReg = Nothing
> End If
>
> Set WshNet = WScript.CreateObject("WScript.Network")
> WshNet.MapNetworkDrive "S:", "\\bea2\users"
> Set WSHNet = Nothing
>
> 'I: Drive - FS02\Img
> '************************
> If (objFSO.DriveExists("I:" = True)) Then
> objNetwork.RemoveNetworkDrive "I:",True,True
> End If
>
> If objFSO.DriveExists("I:") Then
> Set objReg =
> GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
>
> objReg.DeleteKey HKCU, "Network\" & Left("I:", 1)
> Set objReg = Nothing
> End If
>
> Set WshNet = WScript.CreateObject("WScript.Network")
> WshNet.MapNetworkDrive "I:", "\\fs02\img"
> Set WSHNet = Nothing
> ==================================================================================================
>
>
> End of Script
My System SpecsSystem Spec