How to find a usb drive letter trhough the Run box in windows and use it to run a script

Multi tool use
Multi tool use
The name of the picture


How to find a usb drive letter trhough the Run box in windows and use it to run a script



I am trying to run a script from the run box in windows. The problem is that this is on a usb and I want to be able to do this on different computers. The usb is called "bashbunny", but the drive letter will change depending on the computer. How do i find the drive letter and launch the script that is on the usb through the Run box?



Sorry if im not able to explain better :)



What I have done so far:


powershell ".((gwmi win32_volume -f 'label=''BashBunny''').Name+'payloadsswitch1r.cmd')"





I don't understand why you would open a command prompt and type in a command to find and launch a script on a USB drive with a known label. A double click in the GUI is much quicker I'd suspect.
– Compo
Mar 9 '17 at 22:58





@compo Actually I am going to set it up with the new bashbunny from hak5 so it is a lot faster to do it through the run box if possible :) and I dont want to open the command prompt, I want to do it through the run box (you know win+r) :)
– Simen K
Mar 9 '17 at 23:10







@Compo They point is I want to plug in the usb and let it do all the work ;) And I was able to do it right now! :D
– Simen K
Mar 9 '17 at 23:37





What is called SCRIPTER and what is called BashBunny? I am confused...
– aschipfl
Mar 12 '17 at 16:13


SCRIPTER


BashBunny





Haha I later changed the label back to bashbunny :)
– Simen K
Mar 12 '17 at 18:07




3 Answers
3



After tinkering a bit I found the solution:


powershell -executionpolicy Bypass ".((gwmi win32_volume -f 'label=''BashBunny''').Name+'payloadsswitch1r.ps1')"



Here is a pure cmd solution (as you also tagged your question accordingly):


(for /F "skip=1" %I in ('wmic Volume where ^(DriveType^=2 AND Label LIKE "BashBunny"^) get DriveLetter') do @for /F %J in ("%I") do @set "DRIVE=%J") && call "^%DRIVE^%payloadsswitch1r.cmd"



Or, with an alternative wmic command line:


wmic


(for /F "skip=1" %I in ('wmic LogicalDisk where ^(DriveType^=2 AND VolumeName^="BashBunny"^) get DeviceID') do @for /F %J in ("%I") do @set "DRIVE=%J") && call "^%DRIVE^%payloadsswitch1r.cmd"



how about to find the drive letter of a USB Card, but the search by the Manufacture or another way.
My problem is that the users change the Label and I need to find the drive letter by the Batch to format that drive in the imaging process.



Some ideas ?





Welcome to StackOverflow SurfBR. However, this does not provide an answer to the question.You can search for similar questions, or refer to the related and linked questions on the right-hand side of the page to find an answer. If you have a related but different question, ask a new question, and include a link to this one to help provide context. See: Ask questions, get answers, no distractions
– Shree
1 hour ago






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

EkaFQ,jYY Lo,1ENU9,KOPVRPWflNLu
OuVYY1KPmkRySdYhSjlxkuiIgJQIdtBUc8dIvYx,E,OGo4l

Popular posts from this blog

Keycloak server returning user_not_found error when user is already imported with LDAP

PHP parse/syntax errors; and how to solve them?

Using generate_series in ecto and passing a value