Change drive letters from command line via a script

Page 4 of 4 FirstFirst ... 234

  1. Posts : 52
    Windows 10
    Thread Starter
       #31

    I think I might have a solution. Since I want it automated so the user does not have to perform the initial steps.

    • In the Windows installations \sources folder, create the folder $OEM$\$$\setup\scripts and place a script called setupcomplete.cmd in there
    • The setupcomplete script runs on first boot, scans the drives for two scripts called start.cmd and chgdrive.cmd and copies them to the C:\ drive if they are found, or pops up an error if not
    • If these scripts are found, run start.cmd which figures out which drive needs to be changed based on the username, since the drive configuration is known for each user
    • Once we've figured out which drive needs to be renamed, call chgdrive to do that.
    • Once done, delete the setupocomplete.omd and the two scripts copied to c:\


    In the second last step I could conceivably change all drives that need to be renamed at that point, rather than doing those drives later via the main postintall.cmd script, but I want the output fore those in the log file. I can't create the log file in the initial script because stuff will then be out of order, so start.cmd and cghdrive.cmd initially won't log anything.
      My Computer


  2. Posts : 777
    Windows 7
       #32

    If you create folder "\sources\$OEM$\$1\Scripts", everything inside will be copied to C:\Scripts on the target system.
      My Computer


  3. Posts : 52
    Windows 10
    Thread Starter
       #33

    garlin said:
    If you create folder "\sources\$OEM$\$1\Scripts", everything inside will be copied to C:\Scripts on the target system.
    I'm not fmailiar with how the $1 folder works.

    Will Windows run all scripts it finds there or only copy them to c:\scripts?
    I would still want a script automatically run to identify what drive to change and make that change.

    Additionally, in looking for info @ https://learn.microsoft.com/en-us/wi...iew=windows-11

    I see this;

    The script must not modify the drive letters. This can potentially cause the recovery to fail.

    It appears I would also need a resetconfig.xml file to trigger the execution of the scripts?
      My Computer


  4. Posts : 777
    Windows 7
       #34

    Under \sources\$OEM$, you can create a folder hierarchy where:
    - $1 -> C:\
    - $2 -> D:\
    - $$ -> C:\Windows
    - $1\Scripts -> C:\Scripts

    All files under $OEM$ are automatically copied from the install media to the target PC. So you can expect C:\Scripts\ChangeDrive.bat to be on every PC when SetupComplete.cmd runs.

    The only exception is SetupComplete never runs on PC's with an OEM product key in BIOS (Dell, HP, Lenovo, Asus...)
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 15:41.
Find Us




Windows 10 Forums