0

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+'payloads\switch1\r.cmd')"
aschipfl
  • 33,626
  • 12
  • 54
  • 99
Simen K
  • 49
  • 1
  • 10
  • 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 09 '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 09 '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 09 '17 at 23:37
  • What is called `SCRIPTER` and what is called `BashBunny`? I am confused... – aschipfl Mar 12 '17 at 16:13
  • Haha I later changed the label back to bashbunny :) – Simen K Mar 12 '17 at 18:07

2 Answers2

1

After tinkering a bit I found the solution:

powershell -executionpolicy Bypass ".((gwmi win32_volume -f 'label=''BashBunny''').Name+'payloads\switch1\r.ps1')"
Simen K
  • 49
  • 1
  • 10
0

Here is a pure 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^%\payloads\switch1\r.cmd"

Or, with an alternative wmic command line:

(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^%\payloads\switch1\r.cmd"
aschipfl
  • 33,626
  • 12
  • 54
  • 99