Jump to content

Windos 2003 Server


Recommended Posts

I created a file "abc.bat" to be use as login scrip for network printer and map drive. I copied this file to "sysvol\sysvol\domain.com\script\abc.bat" and under user profile --> Login script typed abc.bat but it is not mapping the drive and not capturing the printer port.

Login script

net use I:\\computername\Account

net us LPT1 \\computernam\10.10.30.26

Can someone help me to find how can I

Map a network drive

Capture a network printer

Thanks

Edited by moinuddin_sh
Link to comment
Share on other sites


Here is an example of a simple VBS logon script. Copy & paste the content, modify it ater your needs, save it as vbs file (filename.vbs), place it under the same folder where your current script is. Don't forget to change the logon script name on the user properties. This script maps user home folder under drive P, should you map user home folder under user properties within AD Users and Computers, remove it either from there or from the script as it will try to overlap the action.

' VBScript.
' Mapping user home folder on the server
Dim oNet, sUser

Set oNet = CreateObject("Wscript.Network")

sUser =oNet.UserName

oNet.MapNetworkDrive "P:", "\\SUN\" & sUser

'Mapping Network Attached Drives
Dim WshNetwork
Set WshNetwork = WScript.CreateObject("WScript.Network")
WshNetwork.MapNetworkDrive "M:", "\\sun\CMT"
WshNetwork.MapNetworkDrive "Q:", "\\sun\Public Folder"
WshNetwork.MapNetworkDrive "R:", "\\venus\IT"
WshNetwork.MapNetworkDrive "S:", "\\sun\Share"
WshNetwork.MapNetworkDrive "W:", "\\sun\Course"
WshNetwork.MapNetworkDrive "X:", "\\EARTH\XALWIN"
WshNetwork.MapNetworkDrive "Z:", "\\sun\CopyScan"


'Mapping Network Attached Printers
Dim net
Set net = CreateObject("WScript.Network")
net.AddWindowsPrinterConnection "\\sun\HPLJ2100", "HPLJ2100"
net.AddWindowsPrinterConnection "\\sun\DELLM5200", "DELLM5200"
net.AddWindowsPrinterConnection "\\sun\DELLM5300", "DELLM5300"
net.AddWindowsPrinterConnection "\\SUN\ScienceCopy", "ScienceCopy"
net.AddWindowsPrinterConnection "\\SUN\EducationCopy", "EducationCopy"
net.AddWindowsPrinterConnection "\\SUN\HouseCopy", "HouseCopy"

'Selecting default printer
Set net = CreateObject("WScript.Network")
net.SetDefaultPrinter "\\sun\DELLM5300"

Link to comment
Share on other sites

Thanks for your usefull reply. Could you please expalin how can I capture a LPT1. I tried following command on the command prompt of a WS and it work fine but through VBscript it gives an error.

Error Expected end of statement

Error Code is 800A0401

net use LPT1: \\Hetifhasvrfpr01\HPLaserJetAccount /persistent:yes

Edited by moinuddin_sh
Link to comment
Share on other sites

Thanks for your usefull reply. Could you please expalin how can I capture a LPT1. I tried following command on the command prompt of a WS and it work fine but through VBscript it gives an error.

Error Expected end of statement

Error Code is 800A0401

net use LPT1: \\Hetifhasvrfpr01\HPLaserJetAccount /persistent:yes

I see no reason for capturing LPT1 unless you have specific program that can print ONLY on LPT1. When you use net.AddWindowsPrinterConnection you add netowk printer connection, and net.SetDefaultPrinter sets default printer. As far as I can remember, there are very few programs (DOS based) that require LTP port to print.

As per your last question, I think you should remove /persistent:yes from your statement

Edited by klasika
Link to comment
Share on other sites

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...