# Batch File to list files from two seperat networks



## Bentley12 (Mar 6, 2013)

Hello,

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.


----------



## Mindweaver (Mar 6, 2013)

You need to use, "*net use*" command.


```
NET USE
[devicename | *] [\\computername\sharename[\volume] [password | *]]
        [/USER:[domainname\]username]
        [/USER:[dotted domain name\]username]
        [/USER:[username@dotted domain name]
        [/SMARTCARD]
        [/SAVECRED]
        [[/DELETE] | [/PERSISTENT:{YES | NO}]]

NET USE {devicename | *} [password | *] /HOME

NET USE [/PERSISTENT:{YES | NO}]
```

Use the "*net use*" command before what you are trying to do in your batch file.


----------

