Jump to content

oemlife

Member
  • Posts

    1
  • Joined

  • Last visited

  • Donations

    0.00 USD 
  • Country

    United States

Posts posted by oemlife

  1. I have gotten a lot of use out of this script, and modified it heavily for my own use.

    I really appreciate the work that’s been done here.

    On that note, I would like to contribute to this group.

    I have seen several posts where people have had issues using USB drives due to the nature of there dynamic allocation of a drive letter.

    I have a script that will find the drive letter of your USB drive, and change it to the drive letter of your choice. I have created this so I can run this script from my USB drive with the drive letter assign as Z:.

    There are a couple of prerequisites that need to be followed first. They have to do with the setup of the USB drive initially.

    My USB drive has 2 partitions. The first partition is a 1GB partition that holds the boot files for WinPE. The second partition holds the script and image files, and is 460GB.

    The 1st partition should be formatted as Fat32, and should be setup to boot your WinPE.

    The following article is a good one for this. (hint look for creating a UFD boot disk)

    http://technet.microsoft.com/en-us/library/cc709665.aspx

    Once you have the WinPE boot created, format the second partition using NTFS, and label the volume IMAGE This is important because the script looks for this drive by its volume label and gets the drive letter.

    The attached zip file contains 4 files.

    startnet.bat (this is an example and should not be coppied to your winpe windows\system32 dir.)

    getUSBLetter.bat (copy this to your WinPE windows\system32 directory)

    chgletter.txt (copy this to your WinPE windows\system32 directory)

    image.bat (copy this to your WinPE windows\system32 directory)

    What are the scripts doing.

    The first script is getUSBLetter.bat.

    This script uses a filesystem object to look at all “hard disks” on your system, then find the volume with the label of “IMAGE” it also sets the drive letter in the variable USB, which can be used in scripts.

    The second task of the script is to change the drive letter that it finds using diskpart. In my case I have a chgletter.txt file that I pass to diskpart that changes the %USB% to Z

    The third part of the script is basically the same as the first, and queries the drive again and resets the variable USB to the new drive letter.

    At the end of this bat file it calls image.bat file that will cd to the drive letter %USB% and starts the wizard.hta.

    I am sure there are better ways to achieve this, but this works well for me, and I haven’t seen any post here to help those users who are looking for a solution.

    I hope this is useful.

    Ken.

    DISCLAIMER:

    This is my first post, please forgive me if I mess it up somehow. I'm also an amateur so my code sucks, but for me it gets the job done.

    I faced a similar problem. I found that WinPE was assigning a different drive letter to the USB drive. The way I figured out which was my usb drive was to query WMI for drive sizes, since I know how big it is. I looked for a drive bigger than 10GB and smaller than 20GB. Fortunately this logic works in my environment. Another assumption is that there's only one drive that size plugged into the server. I have no idea what a for each loop would do if it found more than one. I don't imagine it can assign the value to the string multiple times.

    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") 
    Set colItems = objWMIService.ExecQuery( _
    "SELECT * FROM Win32_DiskDrive WHERE Size < 21474836480 AND Size > 10737418240",,48)

    For Each objItem in colItems
    strDID = (Right(objItem.DeviceID,1))

    After I have the physical drive number assigned to the variable i dynamically generate my diskpart script to assign the usb drive letter to U:

    I suppose it's ghetto, and I'm not sure why I don't just look for the actual byte count of the usb drive.

    Edit:

    I don't have the actual code with me at home. I'll see if I can post it tomorrow.

×
×
  • Create New...