Help with this bit of code in SetupComplete

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

  1. IAmTheDude

    IAmTheDude MDL Member

    Oct 12, 2011
    112
    19
    10
    #1 IAmTheDude, Jul 27, 2015
    Last edited by a moderator: Apr 20, 2017
    Hey all!

    Just looking for a little it of help with this code in SetupComplete.

    Basically Im trying to integrate MultiOEM and Loader together.

    So if MultiOEM cant activate using SLIC then Loader will.

    I found some code donkeys ago but never had a SLIC2.1 BIOS to try it on until I recently modded a couple of mine.

    This is what I had and which doesn't work:

    Code:
    :ACTIVATE
    cscript //nologo %windir%\system32\slmgr.vbs | Find /i "Licensed"
    if %errorlevel% EQU 0 goto :FIRSTLOGON
    
    
    :Windows Loader
    "Windows Loader.exe" /silent /preactivate
    
    
    :FIRSTLOGON
    move /y "%WINDIR%\Setup\Scripts\FirstLogon.cmd" "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\FirstLogon.cmd"
    I suck at code so am stuck :(

    My PCs on W7 are non-UEFI so I only use Loader or certs but if its possible to also add in something like PicoKMS to the script so it checks all possible activation methods that would be awesome!

    This is the last thing I need to do before putting my W7 disc to bed :)

    Many thanks for any help!


    ;edit; Gonna mark this as solved now, check posts 29 & 30 for the findings :)
     
  2. s1ave77

    s1ave77 Has left at his own request

    Aug 15, 2012
    16,104
    24,378
    340
    What language uses your OS?
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. IAmTheDude

    IAmTheDude MDL Member

    Oct 12, 2011
    112
    19
    10
    EN-US I think or EN-GB

    I usually use GB but when doing testing Im just slamming the Next button so probably US!
     
  4. s1ave77

    s1ave77 Has left at his own request

    Aug 15, 2012
    16,104
    24,378
    340
    It's english is the important fact, since you check for 'Licensed' and SLMGR output is localized.

    Afaik the Loader is already part of the MultiOEM, better ask TheGuardian in his thread.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. IAmTheDude

    IAmTheDude MDL Member

    Oct 12, 2011
    112
    19
    10
    Coolio, I didn't know/think that loader was part of it but then again I have very little knowledge of the activation side of things, still getting my head round it all :(
     
  6. s1ave77

    s1ave77 Has left at his own request

    Aug 15, 2012
    16,104
    24,378
    340
    Saw you asked there already ... i'm commitedly not absolutely sure it's a part of the pack, but thought it :g:.

    If not, come back and we'll see further.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  7. s1ave77

    s1ave77 Has left at his own request

    Aug 15, 2012
    16,104
    24,378
    340
    What of this actually failing, the Loader Run or the following Firstlogon copy?
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  8. IAmTheDude

    IAmTheDude MDL Member

    Oct 12, 2011
    112
    19
    10
    #8 IAmTheDude, Jul 27, 2015
    Last edited by a moderator: Apr 20, 2017
    (OP)
    The part I think is failing is the code inbetween that checks if its activated or not by MEOM.

    MEOM on its own activates Windows
    Loader on its own activates Windows
    FirstLogOn works fine

    basically it should be something like:

    Check if MOEM has activated using certs
    if it has then skip Loader and goto FirstLogOn

    If MOEM hasnt activated then run Loader

    Its just that little bit inbetween to check which one to use

    I did also try this as well which i cobbled together from Google but still Loader kicks in.
    Code:
    cscript /nologo %windir%\\system32\slmgr.vbs /xpr | findstr /i /c:" will expire "> NUL 2>&1
    if [%errorlevel%]==[0] (GOTO :WINDOWSLOADER) else (GOTO :FIRSTLOGON)
    
     
  9. s1ave77

    s1ave77 Has left at his own request

    Aug 15, 2012
    16,104
    24,378
    340
    #9 s1ave77, Jul 27, 2015
    Last edited by a moderator: Apr 20, 2017
    Try without the \ ... :g:.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  10. s1ave77

    s1ave77 Has left at his own request

    Aug 15, 2012
    16,104
    24,378
    340
    Btw, i would simply spare the check, i'm not aware of any chance the system could already be activated at this time :g:.

    We talk about Win 7 right?
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  11. IAmTheDude

    IAmTheDude MDL Member

    Oct 12, 2011
    112
    19
    10
    #11 IAmTheDude, Jul 27, 2015
    Last edited by a moderator: Apr 20, 2017
    (OP)
    (Should mention Im not activated on this machine at the moment)

    Ive just tried:

    Code:
    C:\Users\Dude>cscript /nologo %windir%\\system32\slmgr.vbs /xpr | findstr /i /c:" grace period "> c:\xpr.txt
    Searching for "grace period" instead (of licensed) just to get an output and get the result in xpr.txt of

    Code:
    Initial grace period ends 10/08/2015 10:49:20
    So the command seems to be working within Windows but that could be different during SetupComplete though.

    Im currently upgrading to 10RTM on my laptop (test machine) but once its done Ill try without the // and just a single / instead.
     
  12. s1ave77

    s1ave77 Has left at his own request

    Aug 15, 2012
    16,104
    24,378
    340
    See my post above you last :D.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  13. IAmTheDude

    IAmTheDude MDL Member

    Oct 12, 2011
    112
    19
    10
    #13 IAmTheDude, Jul 27, 2015
    Last edited: Jul 27, 2015
    (OP)
    Yeah this is for Win7. Getting ready for 10 so thought Id finnally get my 7 stuff sorted and put to bed.

    It was my understanding that MEOM runs at OOBE before SetupComplete. The cert and theme are installed and the theme can be seen during the user input of the OOBE stuff (Username, password etc) and at that point it was activated.

    Then SetupComplete runs and ideally checks to see if it is activated and if it isnt runs loader.

    Or do the certs get inputted during SetupComplete and all Im doing is overwriting it with Loader?


    A lot of this is me just seeing if it can be done TBH.

    I have several machines that all have different activation methods and Im trying to get it all together in one iso.

    Ive managed to get everything else together like silent installs and tweaks all installed silently etc, this would just be the icing on the cake :D
     
  14. s1ave77

    s1ave77 Has left at his own request

    Aug 15, 2012
    16,104
    24,378
    340
    OK, didn't consider the case a SLIC is found.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  15. s1ave77

    s1ave77 Has left at his own request

    Aug 15, 2012
    16,104
    24,378
    340
    #15 s1ave77, Jul 27, 2015
    Last edited by a moderator: Apr 20, 2017
    try this:

    Code:
    :ACTIVATE
    cscript "%windir%\system32\slmgr.vbs" /dlv | findstr /i /c:" Licensed " 2>nul&&goto:FIRSTLOGON
    :Windows Loader
    "Windows Loader.exe" /silent /preactivate
    :FIRSTLOGON
    move /y "%WINDIR%\Setup\Scripts\FirstLogon.cmd" "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\FirstLogon.cmd"
    
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  16. IAmTheDude

    IAmTheDude MDL Member

    Oct 12, 2011
    112
    19
    10
    #16 IAmTheDude, Jul 27, 2015
    Last edited by a moderator: Apr 20, 2017
    (OP)
    Sorry for the tardy reply, test machine still installing 10 so just wiped and tested on main machine.

    Loader still runs with that.

    It feels like we are so close, just that tiny bit of code lol

    Have attached a snap of OEM Query Tool during first stage of OOBE just to cofim that the certs are installed and its all activated etc. Just to double check that it wasnt something conflicting or such.
     

    Attached Files:

  17. s1ave77

    s1ave77 Has left at his own request

    Aug 15, 2012
    16,104
    24,378
    340
    #17 s1ave77, Jul 27, 2015
    Last edited by a moderator: Apr 20, 2017
    Hmm ...

    Code:
    :ACTIVATE
    cscript "%windir%\system32\slmgr.vbs" /dlv | findstr "Licensed" 2>nul&&goto:FIRSTLOGON
    :Windows Loader
    "Windows Loader.exe" /silent /preactivate
    :FIRSTLOGON
    move /y "%WINDIR%\Setup\Scripts\FirstLogon.cmd" "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\FirstLogon.cmd"
    
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  18. s1ave77

    s1ave77 Has left at his own request

    Aug 15, 2012
    16,104
    24,378
    340
    Problem i see is, i'm not sure about the license status in that very moment, it might be an idea to move this part from setupcomplete to firstlogon stage of the Setup.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  19. IAmTheDude

    IAmTheDude MDL Member

    Oct 12, 2011
    112
    19
    10
    Hmmm

    Ill give this latest one a shot now then might have to have a look at adding it to my firstlogon.

    If I have to Ill use the 'activation' part as FirstLogOn, reboot to be sure, then silent install apps and cleanup after.

    Logic is saying it is possible. I found the original code in someone elses SetupComplete back when these 'custom preactivated releases' were common so it seems it may have worked or at least they thought it worked at some point.

    Off to try the latest change...
     
  20. Flipp3r

    Flipp3r MDL Expert

    Feb 11, 2009
    1,965
    908
    60
    You could just have some common certificates in your C:\Windows\System32\OEM folder (MSI, Asus, etc) and just install with Win7 slp key.
    Windows will choose correct cert & be auto activated. No need for any scripts...
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...