![]() |
|
[Shell] USB stick, FINDSTR - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [Shell] USB stick, FINDSTR (/showthread.php?tid=5214292) |
USB stick, FINDSTR - gogglebot - Mar 24, 2016 Hi guys, I've not really used FINDSTR before, I did have an example of it's usage which I could have copied over but I can't find it... 😭 the SS64 page is confusing me so I've come here; I'd like to be able to show a list of drives on the computer AND the name of the drive (so say if I'd named my usb stick to "goggleStick") Given how if I put that stick into another computer, it's drive letter may be different, but it's name would be the same. I'd like to be able to use some sort of find command on a list of drives, to locate it by it's name, then get the drive letter out of the list, and assign that to a variable. Current research into displaying a drive list: I found diskpart list volume (from here) unfortunately it's not possible to simply type in "diskpart list volume" as diskpart must first run, and seperately have "list volume" typed in. This would interrupt a batch script whilst diskpart is running. So that's out. WMIC is good! I found on the same site the suggestion of "wmic logicaldisk get deviceid, volumename, description" to show some drive information, for some reason the output came in the order "description, deviceid (which was the drive letter), volumename (e.g. goggleStick)" I can cut this down to "WMIC logicaldisk get deviceid, volumename" which gives firstly the drive letter, then the name, one per line. then I assume somehow pipe this into a findstr command, which puts it into a variable, then use partial variables to extract the first letter, which will be the drive letter, so I can reference the usb stick's files. "%drivelett%:/folder/file.type" Thanks for any help! 🤗 * - Hackoo - Mar 24, 2016 Hi 🤝 And what did you thing about this code ✌ it comes from this thread : [FixTool] Show all hidden folders and files on your USB pendrive by Hackoo PHP Code So, if this code really help you ; don't forget to rate it 😝 Cheers * - gogglebot - Mar 26, 2016 (Mar 24, 2016 08:55 PM)Hackoo Wrote: Hi 🤝 Hi Hackoo, I don't know how I would apply this to my situation? It appears this just locates the first usb stick it finds..or..something? It's important to my little project that I can find the drive's name and from that name find it's drive letter (e.g. find a drive named "GoggleStick" and find it's drive letter, which could be "F:") I need to do it in that order because I want the script to use a specifically named USBstick of my choice, on any computer, where the drive letter assigned to the drive may vary, due to whatever it is that windows decides on a drive letter. (I cant currently find a usb stick that will let me name it, I think my AV is interrupting it, so for example sake I'll use my CD drive) using Code MIC logicaldisk get deviceid, volumename![]() I'd like to pipe this output into a findstr command to search for the drive name, (e.g. "THE_WALKING_DEAD_S04", and it would find the line that contains this, and put that entire line into a variable "%founddrive%", THIS IS WHERE I'M CLUELESS, because I don't know how to use findstr. Unless there is more I can do with wmic, but I have even less idea there, I've been unable to find findstr in either of the pinned posts here. Thanks again * - Hackoo - Mar 26, 2016 Hi 🤝 We suppose that your USB Stick Name is "goggleStick" so, this batch can return to you its driveletter, just give a try and tell me the result 👍 PHP Code * - gogglebot - Mar 26, 2016 (Mar 26, 2016 08:29 AM)Hackoo Wrote: Hi 🤝 This is excellent! Does exactly what I wanted! :) Thank you Hackoo, were I able, I'd +1 you 👍 I don't quite get how you're singling out the drive letter, is it to do with space " " being a deliminator in the FOR loop, and for each thing it adds one to errorlevel or something, so it just stops after the first bit? However it's done, it's great, I can now make my little project :D |