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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with logon script please

Status
Not open for further replies.

740430

IS-IT--Management
May 31, 2008
4
SE
First; this might be a very easy question, but honestly I know no thing about VB scripting at al.

I just got a job at a school and would like to fix a logon script for the children in the school.
I want the logon sript to do the following:

-Maps the home folder for the user as H:
-map 3 shares on a domain member server as L: and M:
-map a network printers and set one of them as a default printer.
The mapping of the printers will be based on the location of the computer
Exp:
If the location of the computer is room 3 then map \\server1\ printer1
And so on
Then set one of the printers as a default printer.

The reason I want to do the mapping of the printers based on computer location is that the school kids move from room to room.

We have a windows 2003R2 DC and we don’t use fully group policy yet but some are used like pointing my documents to the home folder of each user.

I would be very thankful if some one helps me with writing such script.

Thank you
 
Refer to my FAQ: faq329-5798

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Thanks for the tip markdmac.

I tried very hard and got the following script, and I wonder if I did right, or if there is some thing missing.
the following is all the script I wrote but I don’t want to test it till I check with if I did right or if I missed some thing.

Once again I know no thing about VBscript.

Many thanks for some help here :)

The following script is what I got so far and my quastion is can i use just like you see it?

CODE:

ON ERROR RESUME Next

WshNetwork.RemoveNetworkDrive "H:","True","True"
WshNetwork.RemoveNetworkDrive "L:","True","True"
WshNetwork.RemoveNetworkDrive "M:","True","True"


WSHNetwork.MapNetworkDrive "H:", "\\server\share","True"
WSHNetwork.MapNetworkDrive "L:", "\\server\share","True"
WSHNetwork.MapNetworkDrive "M:", "\\server\share","True"


strLocation = objComputer.Get("location")
If strLocation = "schoolX/room1" Then
objNetwork.AddWindowsPrinterConnection "\\server\printer1"
objNetwork.AddWindowsPrinterConnection "\\server\printer2"
objNetwork.SetDefaultPrinter "\\server\printer1"
Wscript.quit(1)
Else
End If

Wscript.quit
 
You need to declare WSHNetwork and can replace all objNetwork with WSHNetwork.

No need for the following two lines either.

Wscript.Quit(1)
Else

Just add the following under On Error Resume Next

Dim WSHNetwork
Set WSHNetwork = CreateObject("Wscript.Network")

And make the replacement I mention above.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Thanks a lot markdmac for the help :)

just one more qustion:
do i need to do any changes to
strLocation = objComputer.Get("location")
? or it will do the job?
Many thanks
Regards
 
Sorry I missed that one. That line will do nothing for you at the moment. You have not declared objComuter and as that is not a typical object I can't suggest how to fix it. Refer to whatever sample you were using.

You should also have a look at my other FAQ faq329-5908.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Thanks for the help Mark.
At least i have the mapping fixed now thanks to your help.


I will see what i can do to fix it so the script gets the computer location, och install the printer.

Anyone eles knows how to install a network printer based on computer lacation?


Bast Regards
 
Anyone eles knows how to install a network printer based on computer lacation?

Did you look at the other FAQ I directed you to that shows how to detect location and take actions?

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top