Map all shared folder in a machine

Hi,

I want a way where i can specify the shared folder machine name and all the folders are mapped to the machine i am running the script.

Is there a way to do this.

Even set the username password and set as connect on restart.

Regards
Sharath
LVL 11
bsharathAsked:
Who is Participating?
 
bpmurrayCommented:
Oops - incomplete ...

if x%3==x goto :ERR
SET SERVER=%1
SET USERNAME=%2
SET PASSWORD=%3
for /F "skip=7 tokens=1,2" %%A in ('net view \\%SERVER%') do if %%B==Disk net use * \\%SERVER%\%%A %PASSWORD% /user:%USERNAME%
goto :XIT
:Err
echo Usage: %0 ServerName UserName Password
echo where
echo       ServerName is the name of the machine you want to scan
echo       UserName    is the name of the user (who must haver the necessary permissions
echo       Password    is the user's password
:XIT
             
      10.05.2007 at 04:43AM IST, ID: 20019485
0
 
bpmurrayCommented:
Try a batch file with something like this. You use it by passing 3 parameters - the server name, your user name and the password:

if x%3==x goto :ERR
SET SERVER=%1
SET USERNAME=%2
SET PASSWORD=%3
for /F "skip=7 tokens=1,2" %%A in ('net view \\%SERVER%') do if %%B==Disk net use * \\%SERVER%\%%A %PASSWORD% /user:%USERNAME%
0
 
bsharathAuthor Commented:
I get this...
C:\>"map all folders.bat"

C:\>if x == x goto :ERR
The system cannot find the batch label specified - ERR
0
 
bsharathAuthor Commented:
I get this...

C:\>"map all folders.bat"

C:\>if x == x goto :ERR

C:\>echo Usage: "map all folders.bat" ServerName UserName Password
Usage: "map all folders.bat" ServerName UserName Password

C:\>echo where
where

C:\>echo       ServerName is the name of the machine you want to scan
      ServerName is the name of the machine you want to scan

C:\>echo       UserName    is the name of the user (who must haver the necessary
 permissions
      UserName    is the name of the user (who must haver the necessary permissi
ons

C:\>echo       Password    is the user's password
      Password    is the user's password
C:\>

No folders asre mapped...
0
 
bpmurrayCommented:
Well READ the error message!!!!!!!!!!!!!!!!!!!!!!!!!!!

Call it like this:

             "map all folders.bat" myserver myusername mypassword
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.