Hey everyone, I need a little help. I created a VBS script to run and when i run it local it works fine. reports the way i want it too and everything, but yesterday i set it up to run as a logon script and its not working. can anyone help me? thanks!
Yes it is Windows 2003, and i have it placed on a server that i can report too. Here is the script below:
"Option Explicit
Dim objShell, objNetwork,DriveLetter,RemotePath, UserName, ApptoRun, FSO
Dim DriveLetter1, DriveLetter2, DriveLetter3,RemotePath1, RemotePath2, RemotePath3
Dim AllDrives, AlreadyConnected, Network1, Network2,Network3, i
'Here I indicate what drive letters to use
DriveLetter1 = "R:" ' This letter must be in CAPITALS.
DriveLetter2 = "P:"
DriveLetter3 = "W:"
DriveLetter = "H:" 'this is user home dir
'Here is the path to use for the drives
RemotePath = "\\IMISVR4\DNI"
RemotePath1 = "\\IMISVR4\DNI"
RemotePath2 = "\\IMISVR4\DNI"
RemotePath3 = "\\IMISVR4\DNI"
Set Network1 = CreateObject("WScript.Network")
Set Network2 = CreateObject("WScript.Network")
Set Network3 = CreateObject("WScript.Network")
Set objShell = CreateObject("WScript.Shell")
Set objNetwork = CreateObject("WScript.Network")
Set AllDrives = objNetwork.EnumNetworkDrives()
AlreadyConnected = False
For i = 0 To AllDrives.Count - 1 Step 2
If AllDrives.Item(i) = DriveLetter Then AlreadyConnected = True
Next
If AlreadyConnected = True then
objNetwork.RemoveNetworkDrive DriveLetter
'all objshell.Popup lines can be commented out, they are mainly for testing
'if commenting out objshell.Popup comment out the Else also
Else
'objShell.PopUp "Drive " & DriveLetter & " no initial connection"
End if
'this is a commented out line Here is where we extract the UserName
UserName = objNetwork.UserName
'this is a commented out line objNetwork.MapNetworkDrive DriveLetter, RemotePath & "\" & UserName
'objShell.PopUp "Drive " & DriveLetter & " connected successfully."
For i = 0 To AllDrives.Count - 1 Step 2
If AllDrives.Item(i) = DriveLetter1 Then AlreadyConnected = True
Next
If AlreadyConnected = True then
objNetwork.RemoveNetworkDrive DriveLetter1
'objShell.PopUp "Drive " & DriveLetter1 & " disconnected."
Else
'objShell.PopUp "Drive " & DriveLetter1 & " no initial connection"
What do you mean its not working? It doesnt run at all? It errors at a certain line in the code? More info would prove useful to use. How are you executing it, GPO, ADUC, or some other method? Where is the .vbs file, on a network share, do the users have rights to the location you have file in? Could post the code also for a better answer.
Well, when i run the script..like double clicking it, it runs fine. There are no errors or anything. It is on a network share that everyone has access too. i am executing it through GPO.
Script seems fine but im no expert on vbs. Do you have the GPO linked to the OU the user is in? did you try a gpupdate /force on the client and a gpresult to see if the GPO is getting applied to the client? could try a gpupdate /force then log off and log back on, could be the GPO just hasnt been applied at the client.
If you are using Group Policy Management Console you right click on the OU you want to link the GPO to and click Link an existing GPO and you can select the GPO you created.
Based on that question i have to wonder if we are communicating clearly to each other. Why dont you explain to us what GPO you may have created or what GPO you think you are using to run the login script. Then tell us where in the GPO you are running the script(Computer Config or User Config) and what path you used for the script.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.