Help with this bit of code in SetupComplete

Discussion in 'Windows 7' started by IAmTheDude, Jul 27, 2015.

  1. s1ave77

    s1ave77 Has left at his own request

    Aug 15, 2012
    16,104
    24,378
    340
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  2. IAmTheDude

    IAmTheDude MDL Member

    Oct 12, 2011
    112
    19
    10
    #22 IAmTheDude, Jul 27, 2015
    Last edited by a moderator: Apr 20, 2017
    (OP)
    Wow I think it worked!

    Code:
    cscript "%windir%\system32\slmgr.vbs" /dlv | findstr "Licensed" 2>nul&&goto:FIRSTLOGON
    Im positive the Loader's black logo thingy didnt appear this time and just checked OEM Query Tool and it says "SLIC 2.1" still.

    With Loader it says "SLIC 2.1 (Possibly Emulated)" so I think it worked!

    I will try again on my test machine tomorrow. Ill flash it back to SLIC 2.0 and install, Loader should run, then reflash back to SLIC 2.1 modded and install again see if Loader runs or not.

    Think you cracked it though mate!
     
  3. s1ave77

    s1ave77 Has left at his own request

    Aug 15, 2012
    16,104
    24,378
    340
    After discussing this with Daz:

    #1. Loader only runs from setupcomplete by intention. This is to show the Warning, so it cannot be misused by Scammers.

    #2. Simply run it by default. It will check and only install key and cert.

    #3. Or use either OEM Pack or Loader.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. s1ave77

    s1ave77 Has left at his own request

    Aug 15, 2012
    16,104
    24,378
    340
    #24 s1ave77, Jul 27, 2015
    Last edited by a moderator: Apr 20, 2017
    Even better :good3:.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. The_Guardian

    The_Guardian Contributor

    May 7, 2012
    2,054
    6,803
    90
    #25 The_Guardian, Jul 27, 2015
    Last edited by a moderator: Apr 20, 2017
    This is ok to use if English language but if another language this check will fail. Just letting you know ahead of time. ;)
     
  6. s1ave77

    s1ave77 Has left at his own request

    Aug 15, 2012
    16,104
    24,378
    340
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  7. IAmTheDude

    IAmTheDude MDL Member

    Oct 12, 2011
    112
    19
    10
    English is fine for me, I barely speak it and its my only language :eek:

    I'm sure if needed it could be altered to find the string in the other languages though.

    Interesting, I didnt know about this method.


    I am truly trying to have my cake and eat it by getting the best of MEOM and Loader depending on the machine its installing on.

    If its a SLIC 2.1 then MEOM brands and installs certs but if its an older 2.0 and needs the emulated Loader then MEOM will brand it but Loader will activate it.
     
  8. s1ave77

    s1ave77 Has left at his own request

    Aug 15, 2012
    16,104
    24,378
    340
    #28 s1ave77, Jul 27, 2015
    Last edited by a moderator: Apr 20, 2017
    You can use WMIC to get the license status:

    Code:
    :Status
        for /f "usebackq tokens=2 delims==" %%n in (`"%SystemRoot%\System32\wbem\WMIC.exe" /namespace:\\root\cimv2 path %sls% get RemainingWindowsReArmCount /format:list`) do set r=%%n
        for /f "tokens=2 delims== " %%A in ('"wmic path SoftwareLicensingProduct where (Name LIKE '%%Windows%%') get LicenseStatus /format:list"') do (set status=%%A)&&(if !status! geq 1 goto:License)
    :License
        set /a grace=grace/60/24
        if %status% EQU 6 set "license=^< EXTENDED GRACE Left: %grace% days ^>" & color 1F
        if %status% EQU 5 set "license=^< NOTIFICATION ^>" & color 4F
        if %status% EQU 4 set "license=^< NON GENUINE GRACE Left: %grace% days ^>" & color 1F
        if %status% EQU 3 set "license=^< OOT GRACE Left: %grace% days ^>" & color 1F
        if %status% EQU 2 set "license=^< OOB GRACE Left: %grace% days ^>" & color 1F
        if %status% EQU 1 set "license=^< LICENSED ^>"
        if %status% EQU 0 set "license=^< UNLICENSED ^>"& color 1F
    
    In your case it's sufficient to check for '1' what means licensed.


    You can try with this instead of the SLMGR check:

    Code:
    for /f "tokens=2 delims== " %%A in ('"wmic path SoftwareLicensingProduct where (Name LIKE  '%%Windows%%') get LicenseStatus /format:list"') do if "%%A"=="1" goto:FIRSTLOGON
    
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  9. IAmTheDude

    IAmTheDude MDL Member

    Oct 12, 2011
    112
    19
    10
    #29 IAmTheDude, Jul 28, 2015
    Last edited by a moderator: Apr 20, 2017
    (OP)
    Did some testing to day on laptop.

    This is definitely working:

    Code:
    :LICENSECHECK
    for /f "tokens=2 delims== " %%A in ('"wmic path SoftwareLicensingProduct where (Name LIKE  '%%Windows%%') get LicenseStatus /format:list"') do if "%%A"=="1" goto:FIRSTLOGON
    
    
    :WINDOWSLOADER
    "Windows Loader.exe" /silent /preactivate
    
    
    :FIRSTLOGON
    
    Heres what I did for reference:
    Flashed BIOS back to original SLIC 2.0
    MOEM branded but didn't activate (pic 01)
    Loader kicked in and used emulated SLIC 2.1 (pic 02)

    Flashed to modded 2.1
    MOEM branded and also inserted certs (pic 03)

    Score!

    I did have an issue though, it looked liked it skipped everything else once it had checked it was activated, it didnt GOTO:FIRSTLOGON jut ended SetupComplete and loaded the desktop.

    Heres what it should have done after:
    Code:
    :FIRSTLOGON
    move /y "%WINDIR%\Setup\Scripts\FirstLogon.cmd" "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\FirstLogon.cmd"
    
    
    CALL "%WINDIR%\reboot1.bat"
    
    I use these rather than the reg keys as I could never get it to 'stick' and runonce reg keys never started. Same with reboot, I have to CALL a batch for it to reboot. I reboot due to importing some tweaks in a reg before :LICENCECHECK that dont stick without a reboot.

    Anyway, it could just be a fluke that it skipped it, now Ive sorted W10 out I can go back to a clean dual boot so will see if it skips it on my main PC tomorrow.

    :)
     

    Attached Files:

  10. IAmTheDude

    IAmTheDude MDL Member

    Oct 12, 2011
    112
    19
    10
    #30 IAmTheDude, Jul 29, 2015
    Last edited by a moderator: Apr 20, 2017
    (OP)
    Hmm so that previous it of code is definitely skipping firstlogon and reboot.

    So.

    Just to finally put this to bed I have gone back to the previous cscript code which is working fine.

    Code:
    cscript "%windir%\system32\slmgr.vbs" /dlv | findstr "Licensed" 2>nul&&goto:FIRSTLOGON
    For anyone else who stumbles on this for whatever reason, for a different language you would just need to change the "Licensed" string of the language you are in.

    Many thanks to all those who chimed in, very much appreciated considering how late I am to the Windows 7 party :D