setupcomplete

Discussion in 'Windows 10' started by NICK@NUMBER11, Dec 12, 2015.

  1. NICK@NUMBER11

    NICK@NUMBER11 MDL Expert

    Mar 23, 2010
    1,503
    720
    60
    #1 NICK@NUMBER11, Dec 12, 2015
    Last edited by a moderator: Apr 20, 2017
    the scrip works fine but does not delete the directory... under windows 10
    RMDIR /S /Q "C:\Windows\Setup\Scripts"



    Code:
    @ECHO OFF
    cd %~dp0
    
    start /wait Silverlight_x64.exe /Q
    start /wait Windows-KB890830-x64-V5.31.exe /Q
    
    
    @echo off
    pushd %~dp0
    
    ::::::::::BEGIN ACTIVATION STUFF::::::::::::::::::::::
    :Install Exclusion in Windows Defender for future blocks. Has to be done during Windows Setup or you won't have permissions.
    REG ADD "HKLM\SOFTWARE\Microsoft\Windows Defender\Exclusions\Paths" /v "%WinDir%\AutoKMS\AutoKMS.exe" /D 0 /T REG_DWORD /F
    
    :Activate Windows
    %WinDir%\AutoKMS\AutoKMS.exe
    set status=
    
    for /l %%x in (1, 1, 3) do (
    for /f "tokens=2 delims== " %%A in ('"wmic path SoftwareLicensingProduct where (Name LIKE '%%Windows%%') get LicenseStatus /format:list"') do (
          if %%A geq 1 set status=%%A
    )
    
    if %status% EQU 1 Goto :END-ACTIVATION-STUFF
    %WinDir%\AutoKMS\AutoKMS.exe
    )
    :END-ACTIVATION-STUFF
    
    RMDIR /S /Q "C:\Windows\Setup\Scripts"
    exit
     
  2. xinso

    xinso MDL Guru

    Mar 5, 2009
    12,699
    13,700
    340
    Any readonly leftover in Scripts folder?

    Try this:

    cd\
    rd /s /q %WinDir%\Setup\Scripts >nul 2>&1
    exit
     
  3. NICK@NUMBER11

    NICK@NUMBER11 MDL Expert

    Mar 23, 2010
    1,503
    720
    60
    No read only files, will try your code now in vmware
     
  4. xinso

    xinso MDL Guru

    Mar 5, 2009
    12,699
    13,700
    340
    #4 xinso, Dec 12, 2015
    Last edited by a moderator: Apr 20, 2017
    for /l %%x in (1, 1, 3) do (
    for /f "tokens=2 delims== " %%A in ('"wmic path SoftwareLicensingProduct where (Name LIKE '%%Windows%%') get LicenseStatus /format:list"') do (
    if %%A geq 1 set status=%%A
    )

    if %status% EQU 1 Goto :END-ACTIVATION-STUFF
    %WinDir%\AutoKMS\AutoKMS.exe
    )


    How about?

    for /l %%x in (1, 1, 3) do (
    for /f "tokens=2 delims== " %%A in ('"wmic path SoftwareLicensingProduct where (Name LIKE '%%Windows%%') get LicenseStatus /format:list"') do (
    if %%A NEQ 1 %WinDir%\AutoKMS\AutoKMS.exe
    )
    )




    Edit: I found such command is not good enough

    Code:
    C:\windows\system32>wmic path SoftwareLicensingProduct where (Name LIKE '%%Windows%%') get LicenseStatus /format:list
    
    LicenseStatus=0
    
    LicenseStatus=0
    
    LicenseStatus=1
    
    LicenseStatus=0
    
    LicenseStatus=0
    
    LicenseStatus=0
    
    LicenseStatus=0
    
    LicenseStatus=0

     
  5. NICK@NUMBER11

    NICK@NUMBER11 MDL Expert

    Mar 23, 2010
    1,503
    720
    60
    #5 NICK@NUMBER11, Dec 12, 2015
    Last edited by a moderator: Apr 20, 2017
    (OP)
    don,t understand :confused: but think that i may have the correct line now as:

    RD /S /Q "%systemroot%\Setup\SCRIPTS"
     
  6. xinso

    xinso MDL Guru

    Mar 5, 2009
    12,699
    13,700
    340
    #6 xinso, Dec 12, 2015
    Last edited by a moderator: Apr 20, 2017
    No worries. Your original script about activation status check is OK.

    But I still do not think it is good enough.

    Code:
    Name LIKE '%%Windows%%'
    For example, what if Windows is NOT Volume edition?

    Anyway, it will be alright if you make sure that

    1. Volume edition is being used

    2. The AutoKMS.exe will convert/activate Non-Volume edition
     
  7. NICK@NUMBER11

    NICK@NUMBER11 MDL Expert

    Mar 23, 2010
    1,503
    720
    60
    didnt work folder does not get deleited :mad:
     
  8. xinso

    xinso MDL Guru

    Mar 5, 2009
    12,699
    13,700
    340
    #8 xinso, Dec 12, 2015
    Last edited: Dec 12, 2015
    You did not use cd\?

    What files are in Scripts folder?

    These three and the script?

    start /wait Silverlight_x64.exe /Q
    start /wait Windows-KB890830-x64-V5.31.exe /Q
    AutoKMS.exe

    Could you upload your files (Scripts folder) for me to have a test on my PC?
     
  9. NICK@NUMBER11

    NICK@NUMBER11 MDL Expert

    Mar 23, 2010
    1,503
    720
    60
    yes used "cd"

    files are

    Silverlight_x64.exe
    Windows-KB890830-x64-V5.31.exe
    Setupcomplete.cmd
    OOBE.cmd

    only files that gets deleted is OEMInformation.reg :mad:
     
  10. xinso

    xinso MDL Guru

    Mar 5, 2009
    12,699
    13,700
    340
    #10 xinso, Dec 12, 2015
    Last edited: Dec 12, 2015
    Maybe OOBE.cmd is still runng while deleting Scripts folder.

    If this is the case, then you need to use registry RunOnce to delete
    Scripts folder at next boot.
     
  11. NICK@NUMBER11

    NICK@NUMBER11 MDL Expert

    Mar 23, 2010
    1,503
    720
    60
    #11 NICK@NUMBER11, Dec 12, 2015
    Last edited by a moderator: Apr 20, 2017
    (OP)

    its run as this delets the oeminformation.reg file
    Code:
    @echo off
    
    IF EXIST %windir%\HKCU.vbs reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce" /v Run1 /t REG_SZ /d "%windir%\HKCU.vbs" /f >nul
    
    start /w regedit /s %systemroot%\setup\scripts\OEMInformation.reg
    del /F /Q %systemroot%\setup\scripts\OEMInformation.reg
    
    
     
  12. xinso

    xinso MDL Guru

    Mar 5, 2009
    12,699
    13,700
    340
    #12 xinso, Dec 12, 2015
    Last edited by a moderator: Apr 20, 2017
    I suggest that you have a look at Heldigard script. He uses such method to remove Scripts folder at reboot.

    SetupComplete.cmd
    Code:
    @ECHO OFF
    pushd "%~dp0"
    start /wait KMSpico_setup.exe /verysilent /noicons
    regedit /s RunOnce.reg
    timeout /t 120
    shutdown -r -t 0
    popd
    exit
    RunOnce.reg
    Code:
    Windows Registry Editor Version 5.00
    
    [HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce]
    "01-ReActivate"="C:\\Program Files\\KMSpico\\KMSELDI.exe /silent"
    "02-Clean"="C:\\Windows\\Setup\\Scripts\\Clean.cmd"
    Clean.cmd
    Code:
    @ECHO OFF
    RMDIR /S /Q "C:\Windows\Setup\Scripts"
    RD /S /Q "C:\Windows\Setup\Scripts"
    exit
     
  13. NICK@NUMBER11

    NICK@NUMBER11 MDL Expert

    Mar 23, 2010
    1,503
    720
    60
    #13 NICK@NUMBER11, Dec 12, 2015
    Last edited: Dec 12, 2015
    (OP)
    will test it now

    it didnt work :mad:
     
  14. xinso

    xinso MDL Guru

    Mar 5, 2009
    12,699
    13,700
    340
    #14 xinso, Dec 12, 2015
    Last edited by a moderator: Apr 20, 2017
    I reproduced the situation you mentioned above and applied it on VL 10586 Pro. No, it did not work.

    Code:
    ----------------------------------------
    AutoKMS 2.6.0.0 Ran At 2015/12/12 下午 09:51:14.
    Using built-in KMS Server Emulator.
    Attempting To Activate Microsoft Windows
    Attempting to Activate Professional
    <Product activation successful>
    ----------------------------------------
    ----------------------------------------
    AutoKMS 2.6.0.0 Ran At 2015/12/12 下午 09:51:54.
    Using built-in KMS Server Emulator.
    Attempting To Activate Microsoft Windows
    Attempting to Activate Professional
    <Product activation successful>
    ----------------------------------------
    
    
    
    Could you tell me why you use Windows-KB890830-x64-V5.31.exe? It is preinstalled package, isn't it?
     
  15. NICK@NUMBER11

    NICK@NUMBER11 MDL Expert

    Mar 23, 2010
    1,503
    720
    60
    #15 NICK@NUMBER11, Dec 12, 2015
    Last edited by a moderator: Apr 20, 2017
    (OP)
    Got it working now

    setupcomplete

    Code:
    @ECHO OFF
    cd %~dp0
    
    start /wait Silverlight_x64.exe /Q
    start /wait Windows-KB890830-x64-V5.31.exe /Q
    regedit /s RunOnce.reg
    
    ::::::::::BEGIN ACTIVATION STUFF::::::::::::::::::::::
    :Install Exclusion in Windows Defender for future blocks. Has to be done during Windows Setup or you won't have permissions.
    REG ADD "HKLM\SOFTWARE\Microsoft\Windows Defender\Exclusions\Paths" /v "%WinDir%\AutoKMS\AutoKMS.exe" /D 0 /T REG_DWORD /F
    
    :Activate Windows
    %WinDir%\AutoKMS\AutoKMS.exe
    set status=
    
    for /l %%x in (1, 1, 3) do (
    for /f "tokens=2 delims== " %%A in ('"wmic path SoftwareLicensingProduct where (Name LIKE '%%Windows%%') get LicenseStatus /format:list"') do (
    if %%A geq 1 set status=%%A
    )
    
    if %status% EQU 1 Goto :END-ACTIVATION-STUFF
    %WinDir%\AutoKMS\AutoKMS.exe
    )
    :END-ACTIVATION-STUFF
    
    exit
    
    RunOnce
    Code:
    Windows Registry Editor Version 5.00
    
    [HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce]
    "01-Clean"="C:\\Windows\\Setup\\Scripts\\Clean.cmd"
    Clean
    Code:
    @ECHO OFF
    RMDIR /S /Q "C:\Windows\Setup\Scripts"
    RD /S /Q "C:\Windows\Setup\Scripts"
    exit

    :worthy: :worthy: :worthy: Thank you :clap: :clap:
     
  16. Enthousiast

    Enthousiast MDL Tester

    Oct 30, 2009
    47,274
    94,765
    450
    #16 Enthousiast, Dec 12, 2015
    Last edited by a moderator: Apr 20, 2017
    That setupcomplete looks a lot like the one murphy78 uses in his releases?

    @xinso: that kb is the monthly released "malicious software removal tool".
     
  17. NICK@NUMBER11

    NICK@NUMBER11 MDL Expert

    Mar 23, 2010
    1,503
    720
    60
    yeh it just well may have been from him :tasty:
     
  18. xinso

    xinso MDL Guru

    Mar 5, 2009
    12,699
    13,700
    340
    #18 xinso, Dec 12, 2015
    Last edited by a moderator: Apr 20, 2017
    It worked as of:
    Code:
    @ECHO OFF
    cd %~dp0
    
    start /wait Silverlight_x64.exe /Q
    start /wait Windows-KB890830-x64-V5.31.exe /Q
    
    @echo off
    pushd %~dp0
    
    ::::::::::BEGIN ACTIVATION STUFF::::::::::::::::::::::
    :Install Exclusion in Windows Defender for future blocks. Has to be done during Windows Setup or you won't have permissions.
    REG ADD "HKLM\SOFTWARE\Microsoft\Windows Defender\Exclusions\Paths" /v "%WinDir%\AutoKMS\AutoKMS.exe" /D 0 /T REG_DWORD /F
    
    :Activate Windows
    %WinDir%\AutoKMS\AutoKMS.exe
    
    cd\
    RD /S /Q "C:\Windows\Setup\Scripts"
    exit
    So... There is problem in HERE:
    Code:
    @ECHO OFF
    cd %~dp0
    
    start /wait Silverlight_x64.exe /Q
    start /wait Windows-KB890830-x64-V5.31.exe /Q
    
    @echo off
    pushd %~dp0
    
    ::::::::::BEGIN ACTIVATION STUFF::::::::::::::::::::::
    :Install Exclusion in Windows Defender for future blocks. Has to be done during Windows Setup or you won't have permissions.
    REG ADD "HKLM\SOFTWARE\Microsoft\Windows Defender\Exclusions\Paths" /v "%WinDir%\AutoKMS\AutoKMS.exe" /D 0 /T REG_DWORD /F
    
    :Activate Windows
    %WinDir%\AutoKMS\AutoKMS.exe
    set status=
    
    for /l %%x in (1, 1, 3) do (
    for /f "tokens=2 delims== " %%A in ('"wmic path SoftwareLicensingProduct where (Name LIKE '%%Windows%%') get LicenseStatus /format:list"') do (
          if %%A geq 1 set status=%%A
    )
    
    if %status% EQU 1 Goto :END-ACTIVATION-STUFF
    %WinDir%\AutoKMS\AutoKMS.exe
    )
    :END-ACTIVATION-STUFF
    
    RMDIR /S /Q "C:\Windows\Setup\Scripts"
    exit
    BTW, there is another error occured before running AUTOKMS.exe
    Code:
    錯誤: 存取被拒。 (Error: Access denied.)
    ----------------------------------------
    AutoKMS 2.6.0.0 Ran At 2015/12/12 下午 11:00:56.
    Using built-in KMS Server Emulator.
    Attempting To Activate Microsoft Windows
     
  19. NICK@NUMBER11

    NICK@NUMBER11 MDL Expert

    Mar 23, 2010
    1,503
    720
    60
    #19 NICK@NUMBER11, Dec 12, 2015
    Last edited by a moderator: Apr 20, 2017
    (OP)
    Thanks, we as for the stuff in red i really dont know what it does anyway - hopefully murphy78 can help with that as e just may be the original code maker for it :rolleyes:
     
  20. xinso

    xinso MDL Guru

    Mar 5, 2009
    12,699
    13,700
    340
    #20 xinso, Dec 12, 2015
    Last edited: Dec 12, 2015
    You are right.