Jump to content

Recommended Posts

Posted (edited)

Afternoon All

 

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

scripterror.doc

Edited by brahma
Posted

To make things easier i would use a batch script

 

net use: g: "\\sevrer\share"

 

Please can we have a copy of your vbs script code, there is an error in it.

Posted (edited)

there you go, this will work

 

On Error Resume Next
Dim WshNetwork

Set WshNetwork = WScript.CreateObject("WScript.Network")
WshNetwork.MapNetworkDrive "s:", "\\admin\sims"

WScript.Quit

Edited by FN-Greatermanchester
  • Thanks 1
Posted
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.
Posted

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?

 

Many thanks

Posted
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?

 

Many thanks

 

What are you wanting to do with a login script?

Posted

Windows Logon Scripts - VBScript examples to create printers, map network drives

 

VBScript Scripts | ScriptingAnswers.com Essentials

 

Windows Management Script Center

 

Windows Management Script Center

 

drive space report : Drive Space Report (HTA)

 

wisesoft website :

 

VBScript,PowerShell,Batch File,KiXtart and HTA examples for system administration

 

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 :)

Posted

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

Posted
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.

 

Mike.

Posted

More Login Script agro!!

 

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?

Posted
More Login Script agro!!

 

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:

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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...