Anyone use VBScript for their logon script? I have an RM CC3 network and I want to set some PCs up to use AD instead of logging on via RM. I need to map their drives so, having used VBS in the past, set to creating a login script. However, whenever I run the script I get the attached error. My server name is correct as is the sharename.
I'm using the following code:
Option Explicit
Dim WshNetwork
Set WshNetwork = WScript.CreateObject("WScript.Network")
WshNetwork.MapNetworkDrive "S:", "\\admin\sims\"
WScript.Quit
Cant work this out - any ideas?
Cheers
Last edited by brahma; 8th August 2008 at 01:42 PM.
On Error Resume Next
Dim WshNetwork
Set WshNetwork = WScript.CreateObject("WScript.Network")
WshNetwork.MapNetworkDrive "s:", "\\admin\sims"
WScript.Quit
Last edited by FN-GM; 8th August 2008 at 01:56 PM.
Hmm strange. I never use hard coded paths usually though and build mine up from constants set at the top even for a few lines like that. Just habit I suppose as scripts have a tendancy to expand.
FN-Greatermanchester - you are a star!! I've been looking at this for hours - guess I got to the stage where I couldn't see the wood for the trees!! Thanks again.
Incidentally - do you know of a good reference (book or web site) for vbscipt coding that can be used in login scripts?
FN-Greatermanchester - you are a star!! I've been looking at this for hours - guess I got to the stage where I couldn't see the wood for the trees!! Thanks again.
Incidentally - do you know of a good reference (book or web site) for vbscipt coding that can be used in login scripts?
Plenty of resources out there I normally use computer performance website or the activexperts website ( the first walks you through a plathora of examples and how they work and points to note and the second gives you the examples on how to do different things )
wisesoft has script examples as well.
Short of that a google search should give you more
Thaks for the scriptiong websites guys!! Will be spending a lot of time on them today!!
FN-Greatermanchester - I am going to take all my staff PCs and laptops out of RM and just use RM for the students. For the age of my laptops, I am seeing a big overhead with RM running - coupled with the fact that I dont like the restrictions that RM applies.
I am going to use just AD for managing staff, so need a login script for drive mapping and printer mapping etc.
Will also use it for running any extra stuff as and when
Thaks for the scriptiong websites guys!! Will be spending a lot of time on them today!!
FN-Greatermanchester - I am going to take all my staff PCs and laptops out of RM and just use RM for the students. For the age of my laptops, I am seeing a big overhead with RM running - coupled with the fact that I dont like the restrictions that RM applies.
I am going to use just AD for managing staff, so need a login script for drive mapping and printer mapping etc.
Will also use it for running any extra stuff as and when
That's precisely what we do here. Tip from me, make sure you create a completely new OU for all your staff machines and users, and disable policy inheritance on it. That way you won't get any of the RM GPOs clogging up your setup. Also it's worth creating your own security groups as well, and not using the RM default ones, that way you know what they all do and can allocate them to resources as you feel necessary.
I've got my network drives mapping spot on now but am having trouble wiht printers. I want to map a printer for a user based on group membership and have tried the following:
If isMember("Printer_OFFICE1_2600N") Then
WshNetwork.AddWindowsPrinterConnection "\\print-01\OFFICE1_2600N"
Elseif isMember("Printer_RECEPTION_2300DTN") Then
WshNetwork.AddWindowsPrinterConnection "\\print-01\RECEPTION_2300DTN"
ElseIf isMember("Printer_FINANCE_OFFICE_2600N") Then
WshNetwork.AddWindowsPrinterConnection "\\print-01\FINANCE_OFFICE_2600N"
Endif
I am using an account to test this that is only a member of "Printer_RECEPTION_2300DTN" but they get printer "\\print-01\OFFICE1_2600N" mapped and not reception!! I have put some wscript.echo commands in to see what is happening - I am getting an echo from Office1 and not from Reception - the script seems to map to the first printer - regardless of group membership - and then exits without testing the other If statements. Even tho' my user is not a member of Office they get the Office printer and even tho' they are a member of Reception they dont get the reception printer!!
I've got my network drives mapping spot on now but am having trouble wiht printers. I want to map a printer for a user based on group membership and have tried the following:
If isMember("Printer_OFFICE1_2600N") Then
WshNetwork.AddWindowsPrinterConnection "\\print-01\OFFICE1_2600N"
Elseif isMember("Printer_RECEPTION_2300DTN") Then
WshNetwork.AddWindowsPrinterConnection "\\print-01\RECEPTION_2300DTN"
ElseIf isMember("Printer_FINANCE_OFFICE_2600N") Then
WshNetwork.AddWindowsPrinterConnection "\\print-01\FINANCE_OFFICE_2600N"
Endif
I am using an account to test this that is only a member of "Printer_RECEPTION_2300DTN" but they get printer "\\print-01\OFFICE1_2600N" mapped and not reception!! I have put some wscript.echo commands in to see what is happening - I am getting an echo from Office1 and not from Reception - the script seems to map to the first printer - regardless of group membership - and then exits without testing the other If statements. Even tho' my user is not a member of Office they get the Office printer and even tho' they are a member of Reception they dont get the reception printer!!
What am I doing wrong?
Apart from assesing who is in what group you code is doing exactly what it is told to:
Currently its excecution path is like this:
If a member of Printer_OFFICE1_2600N then map printer else (if not a member) then check if user is a member of Printer_RECEPTION_2300DTN, if so map that printer, if not then check the next one.
I think what you want to do is break up your if statments so that they are assessed individually:
Code:
If isMember("Printer_OFFICE1_2600N") Then WshNetwork.AddWindowsPrinterConnection "\\print-01\OFFICE1_2600N"
If isMember("Printer_RECEPTION_2300DTN") Then WshNetwork.AddWindowsPrinterConnection "\\print-01\RECEPTION_2300DTN"
If isMember("Printer_FINANCE_OFFICE_2600N") Then WshNetwork.AddWindowsPrinterConnection "\\print-01\FINANCE_OFFICE_2600N"
You should echo the result of your isMember procedures to see which ones are being assessed as true.