How to call a batch script from SetupComplete.cmd

Discussion in 'Scripting' started by ceo54, Apr 17, 2020.

  1. ceo54

    ceo54 MDL Senior Member

    Aug 13, 2015
    341
    61
    10
    Hello,

    I have to use Abbodi's KMS script from the Scripts folder to activate the windows while installation. They already provide a script to use as setupcomplete but the problem is I'm already using a setupcomplete with some other commands. Now I have to call the KMS script from my setupcomplete, for it I have added following line at the end of my setucomplete

    Code:
    call %WINDIR%\Setup\Scripts\Activate.cmd
    Now my questions are, will this work ?

    Will the Abbodi's script show the command prompt window or will it run without showing the cmd window like the setupcomplete ?

    Lastly, do I have to include inverted commas (" ") in the path ?

    Thank you for the help.

    Edit: One more thing, do I have to use exit at the end ? normally I don't use that.
     
  2. Enthousiast

    Enthousiast MDL Tester

    Oct 30, 2009
    32,809
    52,624
    450
    As explained in the readme for 38f, when you already have a setupcomplete.cmd just rename setupcomplete.cmd from the pre-made KMS_VL_ALL v38f $OEM$ folder to something else and call that cmd in the existing setupcomplete.cmd.

    or do this for AIO:
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. ceo54

    ceo54 MDL Senior Member

    Aug 13, 2015
    341
    61
    10
    Thanks for the reply @Enthousiast I've generated the OEM folder and this is what I got in setupcomplete:
    Code:
    @echo off
    call %~dp0KMS_VL_ALL_AIO.cmd /s /a
    cd \
    (goto) 2>nul&rd /s /q "%~dp0"
    So I need to paste this code in my setupcomplete ?

    Now two things, first will the abbodi's script show the command prompt window ? and secondly do i need to specify "exit" at the end, right after this line (goto) 2>nul&rd /s /q "%~dp0" ?
     
  4. ceo54

    ceo54 MDL Senior Member

    Aug 13, 2015
    341
    61
    10
    Okay I did a test and apparently the kms script shows the command window without any messages. Is there a way to get rid of this window all together and run the script in background ?
     
  5. Enthousiast

    Enthousiast MDL Tester

    Oct 30, 2009
    32,809
    52,624
    450
    #5 Enthousiast, Apr 17, 2020
    Last edited: Apr 17, 2020
    What does the cd \ do and the (goto) ....?

    The /s is for silent, so no windows shown when it runs.
    The /a is for autorenewal

    There should be no need for exit commands (i am not a coder, but the exit command can stop things from running.

    You only need to insert the shown line for calling the kms_vl_all.cmd to have it run by your setupcomplete.

    When you use the pre-made $OEM$ folder from v38f:

    rename the setupcomplete.cmd from the folder to kms_vl_all.cmd and call it from your setupcomplete.cmd and all will run silent and with autorenewal.

    When you use the KMS_VL_ALL.cmd use the call line given in the readme:
    Code:
    call %~dp0KMS_VL_ALL_AIO.cmd /s /a
    and put KMS_VL_ALL_AIO.cmd in the scripts folder.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  6. ceo54

    ceo54 MDL Senior Member

    Aug 13, 2015
    341
    61
    10
    Thank you for staying with me @Enthousiast

    cd \ is to go to the root of the directory. And the (goto) 2>nul&rd /s /q "%~dp0" (last line) is to delete the folder and everything in it from which the script is being run.

    Everything works as intended except for that the script shows the console window. /S switch is only suppressing the messages. Command window is still there.

    I want this entire operation to go completely invisible.

    I understood about the exit message, not needed. Thank you for the tip :)
     
  7. Enthousiast

    Enthousiast MDL Tester

    Oct 30, 2009
    32,809
    52,624
    450
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  8. ceo54

    ceo54 MDL Senior Member

    Aug 13, 2015
    341
    61
    10
  9. ceo54

    ceo54 MDL Senior Member

    Aug 13, 2015
    341
    61
    10