Jump to content

Does this script make sense to you?!?!


Recommended Posts

cmd /c "FOR %%i IN (C D E F G H I J K L N M O P Q R S T U V W X Y Z) DO IF NOT EXIST %%i:\USB_WIN GOTO DLC

GOTO WIN_SETUP

:DLC

DISKPART

SEL DISK 1

SEL PART 1

ASSIGN LETTER=W

GOTO WIN_SETUP

:WIN_SETUP

W:

CD USB_WIN

CALL WIN_SETUP.BAT

Edited by TheReasonIFail
Link to comment
Share on other sites


I'm guessing you want to run this from WinPE...

Using WMI, you should be able to detect a USB Drive better than searching all drive letters for something. Especially if you come across any machines that have a card reader and is detected and assigned a letter. However, the Disk "number" depends on the enumeration the hardware sends the data to WinPE. So you are going to need to take care of the fact that the USB Key will not always be disk 1. If you can get your script to return the drive letter as a variable, you can use SELECT VOL C where C is the drive letter.

Also, you are probably going to want to make a diskpart.txt file, the call diskpart /s diskpart.txt. Because, for example, this as a batch file won't exit diskpart which will screw up the rest of it likely.

Link to comment
Share on other sites

The script doesn't make any sense for me:

You search the drive letter containing the folder usb_win in the root then if you don't find it you mount a partition as drive W: then launch w:\usb_win\win_setup.bat. If you find it, you directly try to launch w:\usb_win\win_setup.bat.

If you want to find the drive letter assigned for the usb drive or assign one if none is already assigned, that wouldn't work. For this kind of job i would first use diskpart script to list volume (already assigned) and redirect the output to file then analyze the file.....

Link to comment
Share on other sites

Yeah, this is very incomplete. I didn't mean to send this off the way it currently is, my apologies.

I'm currently working on a WMI script.

Sometimes I'll put in a new HDD and boot off the USB drive and WinPE will give the USB device the letter C:\ which I use in my Windows XP diskpart script. So I wanted it to change the drive letter of the USB device if it were C:\ but then I thought...hey might as well just have the script always set it to W:\ for the sake of consistancy and that's where I currently stand.

Honestly, I'm so used to writing batch files that it's hard to use anything else. But I'm going to try really hard to not go that route anymore...good bye old friend...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...