Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Logon scripts

Status
Not open for further replies.

Sisco22

IS-IT--Management
Dec 29, 2005
27
US
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!
 
Is it Windows 2003?
Can you show us your script?

Where are you placing the logon script?....

_________________________________
IBM CP, MCP 2000, E60 driver ;-)
 
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

'objShell.PopUp "Drive " & DriveLetter & " disconnected."

'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"

End if

objNetwork.MapNetworkDrive DriveLetter1, RemotePath1
'objShell.PopUp "Drive " & DriveLetter1 & " connected successfully."

For i = 0 To AllDrives.Count - 1 Step 2
If AllDrives.Item(i) = DriveLetter2 Then AlreadyConnected = True
Next

If AlreadyConnected = True then
objNetwork.RemoveNetworkDrive DriveLetter2
'objShell.PopUp "Drive " & DriveLetter2 & " disconnected."

Else

'objShell.PopUp "Drive " & DriveLetter2 & " no initial connection"

End if

objNetwork.MapNetworkDrive DriveLetter2, RemotePath2
'objShell.PopUp "Drive " & DriveLetter2 & " connected successfully."

For i = 0 To AllDrives.Count - 1 Step 2
If AllDrives.Item(i) = DriveLetter3 Then AlreadyConnected = True
Next

If AlreadyConnected = True then
objNetwork.RemoveNetworkDrive DriveLetter3
'objShell.PopUp "Drive " & DriveLetter2 & " disconnected."

Else

'objShell.PopUp "Drive " & DriveLetter3 & " no initial connection"

End if

objNetwork.MapNetworkDrive DriveLetter3, RemotePath3
'objShell.PopUp "Drive " & DriveLetter3 & " connected successfully."


'This section runs the Deski workstation client
AppToRun = "P:\invclient.EXE" 'path to where your Deski client files are

Set FSO = CreateObject("Scripting.FileSystemObject")
CreateObject("Wscript.Shell").Run AppToRun


WScript.Quit
' End of Script"


 
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.

RoadKi11
 
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.
 
Did you add the " " to the beginning and end of the script for our benifit or do you really have them in your script?

 
That was for your benefit. They aren't in the script
 
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.

 
ok..i don't think its being linked. how do i do that?
 
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top