Multi-OEM/Retail Project {MRP} - Mk3

Discussion in 'MDL Projects and Applications' started by mxman2k, Oct 15, 2016.

  1. Dubioza Kolektiv

    Dubioza Kolektiv MDL Addicted

    Dec 27, 2012
    870
    1,470
    30
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  2. Dubioza Kolektiv

    Dubioza Kolektiv MDL Addicted

    Dec 27, 2012
    870
    1,470
    30
  3. vze2mp9g

    vze2mp9g MDL Addicted

    Oct 13, 2012
    660
    117
    30
    Thank you! Could you know where I can put my new computer name "MYCOMPUTER" in the script?

    Code:
    @echo off
    CLS
    color 1f
    TITLE Checking for Admin...
    echo.
    cd %systemroot%\system32
    call :IsAdmin
    
    :StartScript
    REM Enable Unicode
    chcp 65001 >nul
    
    :Start
    SET "NewCName="
    SET "YN="
    SET "strlength=0"
    TITLE Change Computer Name
    cls
    color 1f
    echo.
    echo Certain characters are not allowed, spaces will be converted
    echo to - {minus character}.
    echo.
    echo Pressing just enter without entering anything will close script.
    echo.
    
    echo ** Will attempt to convert to UPPERCASE and 16 Characters MAX or risk of computer boot loops. **
    echo.
    set /p "NewCName=Please enter your new computer/device name: "
    
    IF DEFINED NewCName ECHO %NewCName%>"x" & FOR %%? IN (x) DO SET /A "strlength=%%~z? - 3" & del "x"
    
    IF NOT DEFINED StrLength SET "StrLength=0"
    
    IF "%StrLength%"=="0" GOTO :DoneScript
    
    IF %strlength% GTR 16 echo. & echo Error: More than 16 characters entered... & timeout /t 2 >nul & GOTO :Start
    
    IF NOT DEFINED NewCName GOTO :DoneScript
    
    CALL :UpCase NewCName
    
    REM Change any spaces to - (Minus) to prevent networking errors.
    SET "NewCName=%NewCName: =-%"
    
    REM Misc other Disallowed characters to remove/change.
    REM There are limitations with batch scripting for certain special
    REM characters which cannot be filtered.
    
    SET "NewCName=%NewCName:(=%"
    SET "NewCName=%NewCName:)=%"
    SET "NewCName=%NewCName:\=%"
    SET "NewCName=%NewCName:/=%"
    SET NewCName=%NewCName:^*=-%
    SET "NewCName=%NewCName:?=%"
    SET "NewCName=%NewCName::=%"
    SET NewCName=%NewCName:"=%
    SET "NewCName=%NewCName:^^=%"
    SET "NewCName=%NewCName:!=%"
    SET "NewCName=%NewCName:@=%"
    SET "NewCName=%NewCName:#=%"
    SET "NewCName=%NewCName:^&=%"
    
    :AskLoop
    CLS
    echo.
    echo New Computer Name: %NewCName%
    echo.
    set /p "YN=Is this correct {Y/N and press Enter}: "
    IF /I "%YN%"=="N" GOTO :StartScript
    IF /I "%YN%"=="Y" GOTO :ActionRequest
    GOTO :AskLoop
    
    :ActionRequest
    CLS
    echo.
    echo Modifying registry keys...
    echo.
    reg add "HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ActiveComputerName" /v "ComputerName" /d "%NewCName%" /f >NUL 2>&1
    reg add "HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName" /v "ComputerName" /d "%NewCName%" /f >NUL 2>&1
    reg add "HKLM\SYSTEM\CurrentControlSet\services\Tcpip\Parameters" /v "Hostname" /d "%NewCName%" /f >NUL 2>&1
    reg add "HKLM\SYSTEM\CurrentControlSet\services\Tcpip\Parameters" /v "NV Hostname" /d "%NewCName%" /f >NUL 2>&1
    
    reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v "DefaultDomainName" /d "%NewCName%" /f >NUL 2>&1
    reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v "AltDefaultDomainName" /d "%NewCName%" /f >NUL 2>&1
    
    echo Finished updating the registry...
    echo.
    echo Now to update the DNS cache to match new name...
    
    ipconfig /renew
    ipconfig /flushdns
    ipconfig /registerdns
    
    echo.
    echo Finished updating DNS Cache...
    
    set "computername=%NewCName%"
    
    echo.
    echo Done.
    echo.
    
    Pause
    exit
    
    :DoneScript
    echo.
    echo Nothing entered - script ended.
    echo.
    Pause
    exit
    =====================================================================================
    :IsAdmin
    Reg query "HKU\S-1-5-19\Environment"
    If Not %ERRORLEVEL% EQU 0 (
     Cls & echo. & Echo You must have administrator rights to continue ... & echo.
     Pause & Exit
    )
    Cls
    
    exit /b
    
    :UpCase
    FOR %%i IN ("a=A" "b=B" "c=C" "d=D" "e=E" "f=F" "g=G" "h=H" "i=I" "j=J" "k=K" "l=L" "m=M" "n=N" "o=O" "p=P" "q=Q" "r=R" "s=S" "t=T" "u=U" "v=V" "w=W" "x=X" "y=Y" "z=Z") DO CALL SET "%1=%%%1:%%~i%%"
    exit /b
    
    I appreciate it very much.
    Thank you again! :bye1:
     
  4. vze2mp9g

    vze2mp9g MDL Addicted

    Oct 13, 2012
    660
    117
    30
    THANK YOU for the quick response!

    This is automatically ran after the OS install?
     
  5. Enthousiast

    Enthousiast MDL Tester

    Oct 30, 2009
    49,679
    103,529
    450
  6. mxman2k

    mxman2k MDL Developer

    Jun 20, 2007
    6,320
    21,062
    210
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  7. Dubioza Kolektiv

    Dubioza Kolektiv MDL Addicted

    Dec 27, 2012
    870
    1,470
    30
  8. Dubioza Kolektiv

    Dubioza Kolektiv MDL Addicted

    Dec 27, 2012
    870
    1,470
    30
  9. mxman2k

    mxman2k MDL Developer

    Jun 20, 2007
    6,320
    21,062
    210
    Have been asked recently about the 'new', ( annoying ? ), change in the Explorer's view being set to say 'Today' , 'Yesterday' etc and if possible to reset the view to 'None' as the 'default' view it used to be for all Explorer windows and have it as a new option for MRP...

    After a few days checking changes in the registry when selecting different 'states' of the view parameters, i am now sure that i have worked that part out.

    Will be testing the 'possible' new option over the next few days with various test installations, then if it works correctly during OS installation and not get forcefully reset back, then it will be added into MRP v115.

    This will be a 'General OS' option item as it can affect all Windows OS's, but at moment seems to be Win 10 only, time will tell.

    There will be no revert script as it is not required, you just change the view within the Explorer window you're in to alter the look for that folder/window.

    Results later... :)
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  10. Dubioza Kolektiv

    Dubioza Kolektiv MDL Addicted

    Dec 27, 2012
    870
    1,470
    30
  11. Dubioza Kolektiv

    Dubioza Kolektiv MDL Addicted

    Dec 27, 2012
    870
    1,470
    30
  12. mxman2k

    mxman2k MDL Developer

    Jun 20, 2007
    6,320
    21,062
    210
    Nice to see that HP/Compaq seems to have been mastered and i can't remember the last time one slipped up MRP and failed to detect the brand.

    Query Tool 97.0 will be released within the next 24hrs, it just on last minute thrash testing. :D

    The 115.0 MRP will all being well be ready by the end of this weekend. Just a few cosmetic bits to sort out, also the changelog etc...
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  13. mxman2k

    mxman2k MDL Developer

    Jun 20, 2007
    6,320
    21,062
    210
    Query Tool v97.0 has been uploaded, 2nd post download link, password and hashes updated. :)

    + Updated the headers to separate certain sections clearer.

    + Moved some sections and text into new placements.

    + Added more MS Office information, (under its new header), such as the Stock Keeping Unit ID (SKU ID), Globally Unique IDentifier (GUID) used for checking, reference type, if 32/64 bit Office was installed, last 5 digits of the product code and any error codes/reason text. The Office Error Code Database will expand as new codes are added/found.

    + Some code optimizations.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...