| 1. |
Solve : Batch removable drive help? |
|
Answer» Hi I'm having trouble making a batch file that: Code: [Select]@echo off Is there any way to display a DIR of each drive? I tried adding set dv=!DriveU%%a! dir /b /s %dv% to the script withing the for loop, but I have no idea what the ! does.Thanks for replying so soon and thanks for your help but how would i use that system to make it so it picks up the primary usb and blacklists it and then copy's to all the secondary usb's? I relies that making it leave the label and the icon of the existing autorun is asking a bit much but i figure with this system i can use my 1TB as the master with its custom icon and label and then the rest can have a different one. Code: [Select]setlocal enabledelayedexpansion set UsbNum=0 for %%a in (c d e f g h i j k l m n o p q r s t u v w x y z) do ( for /f %%h in ('fsutil fsinfo drivetype %%a:^|findstr "Removable"') do ( set /a UsbNum+=1 set DriveU!UsbNum!=%%h ) ) echo You have !UsbNum! removable drives, list as below: for /l %%a in (1,1,!UsbNum!) do ( echo.!DriveU%%a! ) endlocal pause And it does look like an autorun virus because in a very loose sense of things it is because it changes the autorun file without prompt. Many Thanks crackrucklesQuote from: Helpmeh on April 28, 2009, 04:37:47 PM Is there any way to display a DIR of each drive? I tried adding Try this one. Code: [Select]@echo off setlocal enabledelayedexpansion set UsbNum=0 for %%a in (c d e f g h i j k l m n o p q r s t u v w x y z) do ( for /f %%h in ('fsutil fsinfo drivetype %%a:^|findstr "Removable"') do ( set /a UsbNum+=1 set DriveU!UsbNum!=%%h ) ) echo You have !UsbNum! removable drives, list as below: for /l %%a in (1,1,!UsbNum!) do ( echo.!DriveU%%a! set dv=!DriveU%%a! dir /b /s !dv! ) endlocal pause Quote from: Reno on April 27, 2009, 10:45:55 PM ...this looks like autorun-virus to me... Quote from: crackruckles on April 29, 2009, 05:08:08 AM ...And it does look like an autorun virus because in a very loose sense of things it is because it changes the autorun file without prompt... Why are you wanting to do this, for malicious purposes? its not for a virus if i was going to make an autorun virus i wouldn't make it in batch. i was just hoping for an easy to use way to change all my autorun files on all my portable devices at once without having to spend time doing them manually. The reason i decided to go with batch to start with was how easy it is to modify for further use. Many Thanks crackrucklesHow many portable devices do you use that a SIMPLE copy and paste would take to long? Quote from: mroilfield on May 10, 2009, 04:37:10 AM How many portable devices do you use that a simple copy and paste would take to long?Exactly!well i work with around 10,15 so a copy and paste would do it but i like to figure stuff out and this is one of those things that i just want to figure out. at the moment i can get the code to work for one drive but not for all of them. it seems to work on the drive its on and not any of the others plugged in.I'm still using Code: [Select]setlocal enabledelayedexpansion set UsbNum=1 for %%a in (e f g h i j k l m n o p q r s t u v w x y z) do ( for /f %%h in ('fsutil fsinfo drivetype %%a:^|findstr "Removable"') do ( set /a UsbNum+=4 set DriveU!UsbNum!=%%h ) ) echo You have !UsbNum! removable drives, list as below: for /l %%a in (1,1,!UsbNum!) do ( echo.!DriveU%%a! ) if EXIST !DriveU%%a!\Autorun.inf goto error1 echo [autorun] > !DriveU%%a!\Autorun.inf echo label: "Craigs Usb"> !DriveU%%a!\Autorun.inf echo shellexecute= "..!DriveU%%a!\1.bat" >> !DriveU%%a!\Autorun.inf echo ;open="..!DriveU%%a!\1.bat" >> !DriveU%%a!\Autorun.inf any ideas? p.s. anybody else have problems with this message box bouncing up when you put the code tag in? Many thanks crackrucklesQuote from: fat_basterd21 on April 27, 2009, 11:57:07 PM
just to point out that batch files isnt programming, its scripting, there is a difference |
|