Results 1 to 6 of 6
  1. #1
    4 Star Lounger
    Join Date
    Feb 2006
    Posts
    504
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Batch file for Mapping Drive (XP)

    Hi,

    I create a batch file for auto mapping network driver and I put it in start up fold of all users profile. Everytime every use logon the computer, the batch file will auto run and map the drive. Please see below for detail of batch file:

    rem Map Network Drives

    NET USE S: serverfolder

    I have the following question regarding this batch file:

    1) Since the batch file will start as user as logon the computer every time, should I have the batch file to check whether if there's a network drive, if yes, then skip. If not, map it.
    2) After the batch file runs, the map drive will be permant or just one time only?

    Thanks

    Regards

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Batch file for Mapping Drive (XP)

    1) I don't think it really matters, but perhaps other will comment on this.
    2) If you run the batch file each time the user logs in, the mapping doesn't have to be permanent, but if you want to, use
    <code>
    NET USE S: serverfolder /PERSISTENT:YES</code>

  3. #3
    4 Star Lounger
    Join Date
    Feb 2006
    Posts
    504
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Batch file for Mapping Drive (XP)

    Thanks, Hans.

    I have another question regarding batch file. I want to create a batch file to install local printer by using IP address & printer driver. But I don't know how to create it?

    Thanks

    Regards

  4. #4
    Plutonium Lounger Leif's Avatar
    Join Date
    Dec 2000
    Location
    U.K.
    Posts
    14,010
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Batch file for Mapping Drive (XP)


  5. #5
    4 Star Lounger
    Join Date
    Feb 2006
    Posts
    504
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Batch file for Mapping Drive (XP)

    Thanks, Leif.

    It's helps. I have to create a standard TCP/IP port first, then add the printer drive and printer name. So how should I create TCP/IP port if the IP is 157.57.50.98 in batch file?

    Thanks

    Regards

  6. #6
    Silver Lounger
    Join Date
    Apr 2001
    Location
    New York, New York, USA
    Posts
    2,328
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Batch file for Mapping Drive (XP)

    To install printers programatically on XP machines, you have to use prnadmin.dll. Unfortunately, this file is not a part of Windows XP installation.

    Download and install Windows Server 2003 Resource Kit Tools

    Copy prnadmin.dll file from the folder where Server Reskit Tools installed to your working folder.
    Read prnadmin.doc for reference. You can write VBS file to install a printer.

    An example of VBS file:

    ----------------Beginnig of VBS file------------------------------
    Option Explicit
    On Error Resume Next

    Call Msg1()
    Sub Msg1()
    Dim intDoIt
    intDoIt = MsgBox("Do you want to install printer ?", _
    vbYesNo + vbInformation, "Printers Installation")
    If intDoIt = vbNo Then
    WScript.Quit
    End If
    End Sub

    Dim WshShell
    Set WshShell = Wscript.CreateObject("Wscript.Shell")
    WshShell.Run "regsvr32 /s prnadmin.dll",1,TRUE
    WshShell.Run "explorer.exe /root,::{20D04FE0-3AEA-1069-A2D8-08002B30309D}::{21EC2020-3AEA-1069-A2DD-08002B30309D}::{2227A280-3AEA-1069-A2DE-08002B30309D}"

    dim oPort
    dim oMaster
    dim oPrinter
    set oPort = CreateObject("Port.Port.1")
    set oMaster = CreateObject("PrintMaster.PrintMaster.1")
    set oPrinter = CreateObject("Printer.Printer.1")

    '*******Creating port**************
    'Creating port in room 001

    oPort.PortName = "IP_157.57.50.98"
    oPort.PortType = 1
    oPort.HostAddress = "157.57.50.98"
    oPort.PortNumber = "9100"
    oMaster.PortAdd oPort
    if Err <> 0 then
    msgbox "There was an error creating a port"
    end if


    '******Installing printer***********************
    'Printer in Room 001

    oPrinter.PrinterName = "Printer 1"
    oPrinter.DriverName = "HP LaserJet 8150 PCL 6"
    oPrinter.PortName = "IP_157.57.50.98"
    oPrinter.DriverPath = ""
    oPrinter.InfFile = "hp8150_6.inf"
    oMaster.PrinterAdd oPrinter
    If Err <> 0 then
    msgbox "There was an error installing the printer"
    end if


    '*******Set default printer************************

    'oMaster.DefaultPrinter = "Printer 1"


    '******Finish notification*************************

    msgbox "Network printer is installed", 0, "Printer Installation"


    -------------------------End of VBS file-------------------------------------------

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •