Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


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

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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

One of my most closely kept secrets is revealed in this discussion How to output text on the same line This question was recently posted in EE by Simon336697 (http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/Batch/Q_2459…
TOMORROW TOMORROW.BAT is inspired by a question I get asked over and over again; that is, "How can I use batch file commands to obtain tomorrow's date?" The crux of this batch file revolves around the XCOPY command - a technique I discovered w…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…

564 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