Universal MediaCreationTool.bat wrapper for ALL versions (1507 - 21H2)

Discussion in 'Windows 10' started by AveYo, Oct 3, 2018.

  1. longbatom

    longbatom MDL Novice

    Oct 1, 2009
    11
    3
    0
    Hi @BAU , I was reading the powershell scripting from your snippet and thanks to all the contents I've learned much. Here may I ask a question: Is there a way to achieve both of the 2 purposes at the same time in one hybrid batch/powershell script:
    1. auto elevate admin privilege (and if failed output error msg, avoid infinite looping)
    2. pass all argvs from outside the script (e.g. test.bat argv1 "argv 2" \argv:3)
    Thank you very much!
     
  2. AveYo

    AveYo MDL Expert

    Feb 10, 2009
    1,836
    5,727
    60
    Check this out:
    Code:
    @echo off
    
    :::: Run as administrator                                      AveYo: no ps\vbs so no av delay, proper parameters pass, loop guard
    set "S=%systemroot%\system32"& set "A=%systemdrive%\Users\Default\AppData\Local\Microsoft\Windows\WinX\Group3\01 - Command Prompt"
    >nul fltmc || ( if +%+% neq +A if exist "%A%.lnk" ( start "" /high "%A%.lnk" /x/d/rset+=A^&cmd /rcall "%~f0" %*&&exit/b0) else (
    >nul reg add "HKCU\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v "%tmp%\cmd.exe" /f /d RUNASADMIN
    >nul robocopy /lev:0 "%S%/" "%tmp%/" cmd.exe& start "" /high "%tmp%\cmd.exe" /x/d/rset+=A^&"%comspec%" /rcall "%~f0" %*&&exit/b0))
    
    whoami /all
    echo [ %* ]
    pause
    exit
    This is what I use lately,
    it's very fast on windows 10 since it just calls cmd, and the lame defender won't randomly delay execution as it happens with ps or vbs commands.
    also has a fallback mode on windows 7 with a copy trick to set compatibility flags for built-in tools.
    safeguarded against loops if for some reason compatibility layer has been crippled by a zealous services "optimization".
    the most simple and effective passing of parameters since it's cmd on all ends, unlike ps or the horrible vbs "solutions".
    and the kicker feature is supporting most special characters spaces brackets whatever in paths, script names and (quoted) arguments.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. longbatom

    longbatom MDL Novice

    Oct 1, 2009
    11
    3
    0
    Hi @BAU , thanks it is amazing idea and would be great help when calling cmd.
    But I might misleadingly express previously. I do want to call powershell.exe, and the argvs are all pass to it.
    Do I need to replace "01 - Command Prompt" with "01a - Windows PowerShell" and cmd with powershell?
    Thanks and best!
     
  4. AveYo

    AveYo MDL Expert

    Feb 10, 2009
    1,836
    5,727
    60
    well, if your script is gonna use powershell anyway then just use powershell for elevation
    Code:
    :::: Relaunch as Admin passing cmdline args
    set _=call "%~f0" %*& fltmc>nul||(powershell -nop -c start cmd -args'/d/x/r',$env:_ -verb runas &&exit/b ||pause&exit/b)
    
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. longbatom

    longbatom MDL Novice

    Oct 1, 2009
    11
    3
    0
    Thank you @BAU ,it's real kickass :)
     
  6. Hacker?pcs

    Hacker?pcs MDL Member

    May 28, 2009
    180
    76
    10
    Just a suggestion, the temporary folders (ESD, etc) could be placed in the same folder as the script or at least the drive the script is running from and not the C drive
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  7. AveYo

    AveYo MDL Expert

    Feb 10, 2009
    1,836
    5,727
    60
    you would think that, but microsoft hard-codes the working folder path and only offers an option to change a temp path where not much i/o happens
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  8. Hal2000

    Hal2000 MDL Junior Member

    Apr 26, 2014
    57
    36
    0
    Can this be used to create the new Windows Server 2022 LTSC, with 10 years support it may be the answer to frequent versions appearing.
     
  9. AveYo

    AveYo MDL Expert

    Feb 10, 2009
    1,836
    5,727
    60
    no. that's a different product unsuitable for consumers even with the desktop experience (and I dont think public esd's for it are available)
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  10. Dark Dinosaur

    Dark Dinosaur X Æ A-12

    Feb 2, 2011
    4,150
    5,958
    150
    Mct fail to load ..
    Any ideas ?
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  11. Jan38

    Jan38 MDL Novice

    Jun 25, 2020
    6
    1
    0
    #151 Jan38, Sep 4, 2021
    Last edited: Sep 4, 2021
    hmmm. noob here, how do i execute this the right way? Once i start the bat file it's responding very slow and does nothing?

    Update, seems it's activated but responding a little slow BUT working :)
     
  12. AveYo

    AveYo MDL Expert

    Feb 10, 2009
    1,836
    5,727
    60
    Windows 11 has come early to MCT..
    (actually, I added it back in September 3th, but "slept" on it so that I could implement a more elegant / reliable way to skip TPM Check with Dynamic Update)
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  13. pc71520

    pc71520 MDL Junior Member

    Feb 12, 2013
    89
    44
    0
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  14. MrKaon

    MrKaon MDL Senior Member

    Jan 23, 2011
    400
    310
    10
    Dynamic Update means Windows 11 will installs updates with no problem on unsupported hardware?
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  15. Enthousiast

    Enthousiast MDL Tester

    Oct 30, 2009
    49,647
    103,302
    450
    Dynamic update is either for updating the ISO:\sources folder or for updating winre.wim, not for circumventing the system requirements.
     
  16. AveYo

    AveYo MDL Expert

    Feb 10, 2009
    1,836
    5,727
    60
    Windows 11 already installs updates with no problem on unsupported hardware if you managed to get it
    It's only feature updates via windows update that are soft-blocked
    That's mainly for insider builds, but also running setup manually under windows (even if it's the same version as the installed one aka in-place update/repair)
    The proposed dynamic update workaround allows manual setup with Dynamic Update on (so that latest setup files are downloaded) as well as getting insider builds like 224xx via windows update
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  17. maddogster

    maddogster MDL Senior Member

    Mar 23, 2015
    319
    112
    10
    will only know on/after oct 5 and oct patch tuesday whether unsupported get updates thru wu or need bypass tool like win 7
     
  18. AveYo

    AveYo MDL Expert

    Feb 10, 2009
    1,836
    5,727
    60
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  19. petros20041

    petros20041 MDL Novice

    Jan 20, 2017
    33
    6
    0