1. Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

Batch File to list files from two seperat networks

Discussion in 'Programming & Webmastering' started by Bentley12, Mar 6, 2013.

  1. Bentley12 New Member

    Mar 6, 2013
    1 (0.00/day)
    Thanks Received:

    I work in a factory where multiple PCs are on seperate VLANs. I need to view contents of a directory from one VLAN called "Admin" and compare it with individual directories from multiple PCs on another VLAN called "Shop" ("Shop" is not part of the Domain)

    I have created a VB script that will compare two txt files and report the diffences. So I am trying to create two text files from each VLAN using a batch file. The batch file will be ran from a PC with two network cards so it can see both VLANs.

    I can easily create the list from the "Admin" network using:
    dir /b \\Server\Share\ > Active.txt

    The "Shop" list is different. It needs a username and password. All Shop PCs have the same user name and password but I'm not sure how to structure the script to create a list from multiple PCs using a user name and password.
    If I open the folders from Windows and enter the credentials then a script like this will work:
    dir /b \\PC_Name1\Share > Programs.txt
    dir /b \\PC_Name2\Share >> Programs.txt

    Using the command above without first opening the folder and entering the credentials gives this error: Logon failure: unknown user name or bad password

    Thanks in advance for any help.
  2. Mindweaver

    Mindweaver Moderato®™ Staff Member

    Apr 16, 2009
    5,139 (2.68/day)
    Thanks Received:
    Statesville, NC
    You need to use, "net use" command.

    [devicename | *] [\\computername\sharename[\volume] [password | *]]
            [/USER:[dotted domain name\]username]
            [/USER:[username@dotted domain name]
            [[/DELETE] | [/PERSISTENT:{YES | NO}]]
    NET USE {devicename | *} [password | *] /HOME
    Use the "net use" command before what you are trying to do in your batch file.
    Crunching for Team TPU

Currently Active Users Viewing This Thread: 1 (0 members and 1 guest)

Share This Page