Net use and Batch file

Posted on 2003-03-09
Medium Priority
Last Modified: 2008-02-01
Weel, i want to do a batch file that does this:

for example i wil use the ip
the batch files checks the shares of this ip by doing
net view \\
it gets the shares:

Now it will get in share c by doing:
net use x: \\\c
Then it will copy a file that i have in c:\ to x:\ and to to all the subdirectories of x:\
after, it does: net use x: /delete
then it will get in share d and sharedocs and do the same thing.

My main problems in this is how it gets the shares and automaticly does net use x:\(SHARE), and how it gets all the subdirectoris in x:\.

Every awser are welcome and apreciated.
thks a lot
Question by:Gfsd
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

bonzai earned 200 total points
ID: 8101895

try my "verry patchy" batchfiles... perhaps someone could improve them... pbarrette??? ;-)

this solution works fine on my w2k machine!

create two batchfiles named GETSHARES.BAT and COPYJOB.BAT

REM -------------begin GETSHARES.BAT------------------------
set workdir=c:\temp\
set YourMachine=

net use x: /D

net view %YourMachine%|find /I /N "disk" > %workdir%findNr.txt
if exist %workdir%\finddisk.txt del %workdir%\finddisk.txt

FOR /F "tokens=2* delims=[]" %%j in (%workdir%\findNr.txt) do (echo %%j >> %workdir%\findDisk.txt)
FOR /F "tokens=1* delims= " %%j in (%workdir%\findDisk.txt) do (call copyjob.bat %%j)

rem -----------cleanup
del %workdir%\finddisk.txt
del %workdir%\findNr.txt
REM --------------end GETSHARES.BAT-------------------------

REM -------------begin COPYJOB.BAT------------------------
net use X: \\%YourMachine%\%1
FOR /R X: %%G IN (.) DO (copy c:\yourfiletocopy.exe %%G)
net use X: /D
REM --------------end COPYJOB.BAT-------------------------

run the getshares.bat file.


LVL 10

Expert Comment

ID: 8105355
Hi all,

I don't know about this one.

You want to enumerate the shares of a series of remote machines, then connect to each share, then copy a file to every subdirectory of that share?

Why? That sounds like a hellova virus delivery system.


Author Comment

ID: 8107053
You really earned this points, thinks a lot

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Using dates in 'DOS' batch files has always been tricky as it has no built in ways of extracting date information.  There are many tricks using string manipulation to pull out parts of the %date% variable or output of the date /t command but these r…
YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question