Link to home
Start Free TrialLog in
Avatar of jzamit
jzamit

asked on

Logon Script GPO - Map Network drives and printers

Hi to all, I am new to VBScript, I am needing to write a GPO logon script in order to map network drives automatically and printers to my clients.

1)
Allready find how to map basically some share to a drive letter but i couldnt find how to map like this:

I need to map \\192.168.2.2\Data\Users\%username% but i cant do that in Vbscript, so i need to find the user who is logging in, place that in a variable and append it to de path.

2) I need to automatically add printers based on the OU the user is. This I dont know how to do it.

Thanks for any help you could give me, cheers!

ASKER CERTIFIED SOLUTION
Avatar of Justin Owens
Justin Owens
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jzamit
jzamit

ASKER

Thanks Dr Ultima, but I allready used that web page  from computerperformance and it keeps failing, i copy pasted that code, changing the names to match my shares and etc, but keeps failing.  Thanks for your advice!

jzamit
Can you paste in the code you are using?  It should be pretty easy to help fine tune it for you.
Avatar of jzamit

ASKER

Of course here is what i copy pasted and changed , note that nothing is written for printers because i couldn`t fix my first problem...

' ----------------------------------------------------' 
Option Explicit
Dim objNetwork 
Dim strDriveLetter, strRemotePath, strUserName
strDriveLetter = "J:" 
strRemotePath = "\\srv-dc01\datos\usuarios" 

' Purpose of script to create a network object. (objNetwork)
' Then to apply the MapNetworkDrive method. Result J: drive
Set objNetwork = WScript.CreateObject("WScript.Network") 
' Here is where we extract the UserName
strUserName = objNetwork.UserName 
objNetwork.MapNetworkDrive strDriveLetter, strRemotePath _
& "\" & strUserName

' Extra code just to add a message box
WScript.Echo " Launch Explorer, check: "& strDriveLetter
WScript.Quit

' End of MapNetworkDrive Example logon script.

Open in new window

Can you use Active Directory to determine users' home folders? (Profiles tab.)

And then, as suggested by DrUltima, use GPO to map printers?
SOLUTION
Avatar of Ron Malmstead
Ron Malmstead
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jzamit

ASKER

Thansk for your help, I have working  the vbs code for mapping to  \\srv-dc01\datos\usuarios\"actualuser" to j, I think it was some copy paste issue that was having me in trouble.

Now I need the printers thing, and i will try to use, GPO in order to accomplish that task. i try it now and post what happend, thanks to all for your help!

Jzamit

Avatar of jzamit

ASKER

xuserx2000: Thanks for your help, I try what you said for the printers, and works fine, but how could I add more printers and set one for default and others optional use?

I used:
CSCRIPT %SYSTEMROOT%\SYSTEM32\PRNMNGR.VBS -ac -p \\servidor\laserjet

Thanks again!
Jzamit
You can add more printers using the same method.
To get a list of commands you can use with that script  ...type the following...
CSCRIPT %SYSTEMROOT%\SYSTEM32\PRNMNGR.VBS /?

Default a printer...
First... list all the printers...
CSCRIPT %SYSTEMROOT%\SYSTEM32\PRNMNGR.VBS -l


To default the printer...  type the following command line + the printer name that shows in the printers listed from the command above.  If the name has spaces be sure to enclose it in quotes...

Example...

CSCRIPT %SYSTEMROOT%\SYSTEM32\PRNMNGR.VBS -t -p "\\servidor\laserjet"

 ,Or

CSCRIPT %SYSTEMROOT%\SYSTEM32\PRNMNGR.VBS -t -p "\\servidor\laserjet 1300"
Avatar of jzamit

ASKER

Thanks for all that help me out! Cheers, jzamit!