Reg Tweaks not working

Discussion in 'Windows 8' started by NICK@NUMBER11, Nov 17, 2012.

  1. NICK@NUMBER11

    NICK@NUMBER11 MDL Expert

    Mar 23, 2010
    1,354
    631
    60
    #1 NICK@NUMBER11, Nov 17, 2012
    Last edited by a moderator: Apr 20, 2017
    Hi,

    I am trying to call some reg tweaks from within a cmd file, but they do not work, everything else works just the reg tweaks do not apply the settings... if I run them by clicking they do, so maybe is the code calling them?

    Code:
    @echo off
    CLS
    TITLE Admin Installation for Windows 8 - Build 17.11.12
    echo.
    echo Getting Installation Files Ready...
    echo Done!
    echo.
    echo Getting Ready Reistry Tweakes
    echo Applying Internet Explorer Registry Tweaks...
    start /w regedit /s IE_Tweaks.reg >nul
    echo Done!
    echo Applying Driver Software Registry Tweaks...
    start /w regedit /s Hardware.reg >nul
    echo Done!
    echo.echo Getting Ready Malicious software removal tool
    echo Installing Malicious Software Removal Tool...
    start /wait windows-kb890830-v4.14.exe /q
    echo Done!
    echo.
    echo Getting Ready Misc apps 
    echo Installing Silverlight... 
    start /wait Silverlight.exe /q
    echo Done!
    echo.
    echo Getting Ready Defender Definitions
    echo Installing Windows Defender Definition updates...
    start /wait mpam-fe.exe /Q
    echo Done!
    echo.
    echo Getting Ready Windows Update
    echo Installing Windows Updates...
    SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
    FOR /R "%~dp0" %%A IN (*.MSU) DO (
            ECHO= Installing %%~nA
            >NUL TIMEOUT /t 3
            WUSA "%%A" /quiet /norestart)
    echo Done!
    ECHO Press any key to restart
    >NUL PAUSE
    SHUTDOWN.EXE /s /t 5
    GOTO :EOF
     
  2. HALIKUS

    HALIKUS MDL Addicted

    Jul 29, 2009
    527
    369
    30
    #2 HALIKUS, Nov 18, 2012
    Last edited by a moderator: Apr 20, 2017
    These are some examples from my old firstlogon.cmd that i ran from my autounattend. Now i opt to use a firstlogon.exe for more control of the process.

    Code:
    ECHO  ** Apply TWEAKS.reg **
    FOR %%f IN (%~dp0FirstLogon\TWEAKS.reg) DO regedit.exe /s %%f
    regedit /s %~dp0FirstLogon\TWEAKS.reg
    SET KEY=HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce
    
    
    
    IF EXIST "%~dp0FirstLogon\Tweaks\*.reg" (
       FOR /F "tokens=*" %%A IN ('DIR /B  "%~dp0FirstLogon\Tweaks\*.reg"') DO (
          regedit /S "%~dp0FirstLogon\Tweaks\%%A"
       )
    )
    
    
    FOR %%f IN (%~dp0FirstLogon\Tweaks\*.reg) DO regedit.exe /s %%f
    
    rem apply reg now
    RUNDLL32.EXE USER32.DLL,UpdatePerUserSystemParameters ,1 ,True
    
    
    
    ECHO  ** Apply FirstLogon exe APPS.  This may take a minute... ** 
    IF EXIST "%~dp0FirstLogon\APPS\*.exe" (
       FOR /F "tokens=*" %%A IN ('DIR /B  "%~dp0FirstLogon\APPS\*.exe"') DO (
          CALL "%~dp0FirstLogon\APPS\%%A"
       )
    )
    
    
    

    Here is an example with progressbar written in autoit. Its cooler than a cmd. I commented out the needed files for fileinstall.

    Code:
    #RequireAdmin
    #region ;**** Directives created by AutoIt3Wrapper_GUI ****
    #AutoIt3Wrapper_Icon=FirstLogon.ico
    #AutoIt3Wrapper_Compression=4
    #AutoIt3Wrapper_UseX64=n
    #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker
    #AutoIt3Wrapper_Add_Constants=n
    #endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
    ;#AutoIt3Wrapper_Compile_Both=y
    ;#NoTrayIcon
    #include <File.au3>
    #include <String.au3>
    #include <Array.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <GUIConstants.au3>
    #include <WinAPI.au3>
    #include <Constants.au3>
    
    Opt("TrayMenuMode", 2)
    
    If FileExists(@TempDir & "\7z.dll") Then
    Exit
    EndIf
    
    DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "int", 1) ; This disables 32bit applications from being redirected to syswow64 instead of system32 by default ;
    If Not IsAdmin() Then; This enables cmd to run as admin
    RunAs($user, $domain, $pass, 0, @ScriptName, @ScriptDir)
    EndIf
    
    #cs
    FileInstall("Apps\7z.dll", @TempDir & "\", 1)
    FileInstall("Apps\7z.exe", @TempDir & "\", 1)
    
    FileInstall("Apps\BCD_TWEAKS.exe", @TempDir & "\", 1)
    FileInstall("Apps\Hide_Updates.exe", @TempDir & "\", 1)
    FileInstall("Apps\ssWPI.exe", @TempDir & "\", 1)
    FileInstall("Apps\Power.cmd", @TempDir & "\", 1)
    FileInstall("Apps\Windows_Sidebar.7z", @TempDir & "\", 1)
    #ce
    
    
    $folder = @ScriptDir & "\"
    $path = (@ScriptDir & "\")
    $m = DirGetSize($path)
    
    
    Func _PinToMenu($File, $Bar = 'Task', $Pin = True)
    If @OSBuild < 7600 Then Return SetError(1)
    If Not FileExists($File) Then Return SetError(2)
    Local $sFolder = StringRegExpReplace($File, "(^.*\\)(.*)", "$1")
    Local $sFile = StringRegExpReplace($File, "^.*\\", '')
    $ObjShell = ObjCreate("Shell.Application")
    $objFolder = $ObjShell.Namespace($sFolder)
    $objFolderItem = $objFolder.ParseName($sFile)
    For $Val In $objFolderItem.Verbs()
    Select
    Case StringInStr($Bar, 'Task')
    If StringInStr($val(), "Tas&kBar") Then
    $Val.DoIt()
    Return
    EndIf
    Case StringInStr($Bar, 'Start')
    If StringInStr($val(), "Start Men&u") Then
    $Val.DoIt()
    Return
    EndIf
    EndSelect
    Next
    EndFunc   ;==>_PinToMenu
    
    
    HotKeySet("{ESC}", "Quit") ;Press ESC key to quit
    While True
    ProgressOn("Escape To Exit", "Firstlogon.  This only runs once.", "Progress", 50, 50)
    Sleep(2000)
    
    
    ProgressSet(10, "Initial tweaks")
    
    ;FileCreateShortcut(@WindowsDir & "\explorer.exe", @DesktopDir & "\Example.lnk", @WindowsDir, "/e,::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", "Tooltip description of the shortcut.", @SystemDir & "\shell32.dll", "^!t", "4", @SW_MINIMIZE)
    ;FileCreateShortcut(@WindowsDir & "\explorer.exe", @DesktopDir & "\Shortcut Example.lnk", @WindowsDir, "/e,c:\", "Tooltip description of the shortcut.", @SystemDir & "\shell32.dll", "^!t", "15", @SW_MINIMIZE)
    
    If @OSArch = "X86" Then
    If @OSVersion <> "WIN_8" Then
    FileInstall("7x86\7x86.7z", @TempDir & "\", 1)
    RunWait(@TempDir & "\7z x " & @TempDir & "\7x86.7z -o" & @HomeDrive & "\ -aoa", @HomeDrive, @SW_HIDE)
    FileDelete(@WindowsDir & "\Setup\FirstLogon\KMS.exe")
    FileInstall("APPS\Windows Explorer.lnk", @UserProfileDir & "\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\Taskbar\", 1)
    EndIf
    
    If @OSVersion <> "WIN_7" Then
    FileDelete(@WindowsDir & "\Setup\FirstLogon\APPS\KB2533552.exe")
    ;FileInstall("8Desktop\8Desktop.7z", @TempDir & "\", 1)
    Run(@TempDir & "\7z x " & @TempDir & "\8Desktop.7z -o" & @UserProfileDir & "\ -aoa", @UserProfileDir, @SW_HIDE)
    FileInstall("8x86\8x86.7z", @TempDir & "\", 1)
    RunWait(@TempDir & "\7z x " & @TempDir & "\8x86.7z -o" & @HomeDrive & "\ -aoa", @HomeDrive, @SW_HIDE)
    RunWait(@TempDir & "\7z x " & @TempDir & "\Windows_Sidebar.7z -o" & @TempDir & "\ -aoa", @TempDir, @SW_HIDE)
    RunWait(@TempDir & "\Sidebar86.cmd", @TempDir, @SW_HIDE)
    ;FileCopy(@WindowsDir & "\setup\Firstlogon\Win8_Safemode.cmd", @DesktopDir & "\", 9)
    FileCreateShortcut(@ScriptDir & "\FirstLogon\KMS\KMS_GUI.exe", @DesktopDir & "\KMS Helper.lnk", @ScriptDir, "", @SW_MINIMIZE)
    _PinToMenu(@WindowsDir & '\explorer.exe', 'Task')
    EndIf
    EndIf
    
    If @OSArch = "X64" Then
    If @OSVersion <> "WIN_8" Then
    FileInstall("7x64\7x64.7z", @TempDir & "\", 1)
    RunWait(@TempDir & "\7z x " & @TempDir & "\7x64.7z -o" & @HomeDrive & "\ -aoa", @HomeDrive, @SW_HIDE)
    FileDelete(@WindowsDir & "\Setup\FirstLogon\KMS.exe")
    FileInstall("APPS\Windows Explorer.lnk", @UserProfileDir & "\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\Taskbar\", 1)
    EndIf
    
    If @OSVersion <> "WIN_7" Then
    FileDelete(@WindowsDir & "\Setup\FirstLogon\APPS\KB2533552.exe")
    ;FileInstall("8Desktop\8Desktop.7z", @TempDir & "\", 1)
    Run(@TempDir & "\7z x " & @TempDir & "\8Desktop.7z -o" & @UserProfileDir & "\ -aoa", @UserProfileDir, @SW_HIDE)
    FileInstall("8x64\8x64.7z", @TempDir & "\", 1)
    RunWait(@TempDir & "\7z x " & @TempDir & "\8x64.7z -o" & @HomeDrive & "\ -aoa", @HomeDrive, @SW_HIDE)
    RunWait(@TempDir & "\7z x " & @TempDir & "\Windows_Sidebar.7z -o" & @TempDir & "\ -aoa", @TempDir, @SW_HIDE)
    RunWait(@TempDir & "\Sidebar64.cmd", @TempDir, @SW_HIDE)
    ;FileCopy(@WindowsDir & "\setup\Firstlogon\Win8_Safemode.cmd", @DesktopDir & "\", 9)
    FileCreateShortcut(@ScriptDir & "\FirstLogon\KMS\KMS_GUI.exe", @DesktopDir & "\KMS Helper.lnk", @ScriptDir, "", @SW_MINIMIZE)
    _PinToMenu(@WindowsDir & '\explorer.exe', 'Task')
    EndIf
    EndIf
    
    
    ProgressSet(20, "Apply BCD tweaks")
    RunWait(@TempDir & "\BCD_TWEAKS.exe")
    
    
    ;apply TWEAKS.reg
    $m = DirGetSize(@ScriptDir & "\FirstLogon\Tweaks")
    ProgressSet(30, "Apply Reg tweaks", "Size " & $m & " KB")
    MsgBox(4096, "Apply Tweaks", "Applying some useful reg tweaks", 1)
    RunWait("Regedit /s " & @WindowsDir & "\Setup\FirstLogon\TWEAKS.reg")
    
    ;apply Setup\FirstLogon\Tweaks
    $sPath = @WindowsDir & "\Setup\FirstLogon\Tweaks"
    FileChangeDir($sPath)
    $RegList = _FileListToArray($sPath, "*.reg", 1)
    If IsArray($RegList) Then
    For $i = 1 To $RegList[0]
    RunWait('regedit' & ' /s' & ' "' & $RegList[$i] & '"')
    Next
    EndIf
    ;Apply reg tweaks now
    Run("RUNDLL32.EXE USER32.DLL,UpdatePerUserSystemParameters ,1 ,True")
    
    
    ;Apply Power Tweaks
    RunWait(@TempDir & "\Power.cmd", @TempDir, @SW_HIDE)
    
    
    ;apply first logon apps
    $m = DirGetSize(@ScriptDir & "\FirstLogon\Apps")
    ProgressSet(40, "Apply first logon apps", "Size " & $m & " KB")
    MsgBox(4096, "Install exe Apps", "Applying Firstlogon apps.  It may take a minute", 1)
    Global $Location = @WindowsDir & "\Setup\FirstLogon\APPS"
    $FileList = _FileListToArray($Location, "*.exe", 1)
    $Argument = StringSplit(" ", ",")
    For $x = 1 To UBound($FileList) - 1
    $Runner = FileGetShortName($Location & "\" & $FileList[$x])
    ConsoleWrite($Runner & @CRLF)
    Sleep(1000)
    RunWait($Runner & $Argument, "", @SW_HIDE)
    Next
    
    
    ;apply first logon apz
    $m = DirGetSize(@ScriptDir & "\FirstLogon\Apps")
    ProgressSet(60, "Apply first logon apz", "Size " & $m & " KB")
    FileInstall("Apps\APZ.cmd", @TempDir & "\", 1)
    RunWait(@TempDir & "\APZ.cmd", "", @SW_HIDE)
    
    
    ;apply MSU
    $m = DirGetSize(@ScriptDir & "\FirstLogon\MSU")
    ProgressSet(70, "Offline Microsoft Updates", "Size " & $m & " KB")
    MsgBox(4096, "MSU", "Applying added Offline MS Updates", 1)
    Run(@WindowsDir & "\Setup\FirstLogon\MSU\MSU.exe")
    
    
    ;Hide Bad KB
    ProgressSet(80, "Hide MS Updates")
    MsgBox(4096, "Hide MS Updates", "Hide MS Updates that are bad", 1)
    RunWait(@TempDir & "\Hide_Updates.exe")
    
    
    ProgressSet(90, "Almost done...")
    MsgBox(4096, "Almost done", "Applying Firstlogon.cmd, User Settings and ssWPI", 1)
    
    
    ;tidy up useless files
    FileDelete(@StartupCommonDir & "\FirstLogon.lnk")
    FileDelete(@StartMenuCommonDir & "\Default Programs.lnk")
    FileDelete(@HomeDrive & "\ShowWPI.ini")
    FileDelete(@HomeDrive & "\*.BAK")
    FileDelete("D:\*.BAK")
    FileDelete("E:\*.BAK")
    FileDelete("F:\*.BAK")
    FileDelete("G:\*.BAK")
    DirRemove(@HomeDrive & "\D\", 1)
    DirRemove("c:\D\", 1)
    DirRemove(@WindowsDir & "\PnPdrvrs", 1)
    ;Delete MSU
    DirRemove(@WindowsDir & "\Setup\FirstLogon\MSU", 1)
    ;sidebar settings
    FileCopy(@WindowsDir & "\Setup\FirstLogon\SidebarSettings.ini", @UserProfileDir & "\AppData\Local\Microsoft\Windows Sidebar\Settings.ini", 9)
    FileCopy(@WindowsDir & "\Setup\FirstLogon\SidebarSettings.ini", "C:\Users\Default\AppData\Local\Microsoft\Windows Sidebar\Settings.ini", 9)
    
    ;apply firstlogon.cmd
    ;RunWait(@ComSpec & ' /c ' & @WindowsDir & "\Setup\FirstLogon.cmd")
    
    ;apply Enterprise KMS, if enterprise and my pe installer was used
    ;Run(@WindowsDir & "\Setup\FirstLogon\KMS.exe")
    
    ;Creating God Folder. Like control panel with all of the options.
    ;MsgBox(4096, "God Folder", "Creating God shortcut to desktop", 1)
    ;DirCreate(@UserProfileDir & "\Desktop\GodMode.{ED7BA470-8E54-465E-825C-99712043E01C}")
    
    ;apply Settings.exe
    Run(@WindowsDir & "\Setup\FirstLogon\Settings\Settings.exe")
    
    ;run sswpi
    RunWait(@TempDir & "\ssWPI.exe")
    
    Sleep(1000)
    ProgressSet(100, "Done", "Complete")
    Sleep(1000)
    ProgressOff()
    MsgBox(0, 'Finish', 'Firstlogon.exe done', 3)
    Exit
    
    WEnd
    Func Quit()
    Exit
    EndFunc   ;==>Quit
    
    
    
     
  3. NICK@NUMBER11

    NICK@NUMBER11 MDL Expert

    Mar 23, 2010
    1,354
    631
    60
    I like the autoit script will have a play around with that...:)