Scripting Question

How do I remove some of the data from a registry string with a KScript?

06/09/2014 8801 views

Im trying to modify the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon string: Userinit

After the system image is deployed the Library window pops up after login.  I need to remove the C:\Windows\System32\KUsrInit.exe, from String name: Userinit. 

The Userinit string only needs to have: C:\Windows\system32\userinit.exe,

This is the currently incorrect String Value: C:\Windows\system32\userinit.exe,C:\Windows\System32\KUsrInit.exe,

Im trying to do this with a KScript and cannot get the set a regisrty value option to work.

Kace Appliance version: 5.5.90547

Answer Summary:
Changing the reg key command to: hklm64 did the trick!! Thanks SMal.tmcc
0 Comments   [ + ] Show comments


All Answers


if you have the kace agent installed these are the correct values

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]

without agent should be

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]

before you remove this read:


but if want to use the kbox to remove part of the agent you do it this way

rule of thumb is export and create a .reg merge file of the keys you want.  lose the header and paste that into the policies box registry file:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]

the second line removes a key you want to remove if you are switching the usrinit back to default

Answered 06/09/2014 by: SMal.tmcc
Red Belt

  • these are 6.0 screen shots but is the same thing under 5.5
  • I cannot get the change to take effect on the test computer. I feel like its how i'm deploying the script thats causing the failure. The script is running as local system and Microsoft Windows OS version.

    This is exactly what is in my registry file on Kace.

    The Kace agent is already on the systems since its installed on the syspreped image.

    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]

    I set the alert user notification to verify its actually running. I have tried "it seems" every possible combination of the parameters to get the change to take effect.
    • are these 64 bit machines
      • Yes, 64 bit image.
      • try making the registry key command hklm64\software\... instaead of HKEY_LOCAL_MACHINE\SOFTWARE
      • you need a push for 32 bit and one for 64 bit machines with changes like this. The kace agent is 32 bit so it will call programs from windows\syswow64 and registry calls like this get written to wow6432node instead of where you want. If drill down under the wow6432node keys to that same spot you will see those keys you tried to write to hklm\software on the machines you ran when it did not have the "64" in the script. by adding the 64 you are forcing the 32bit regedit command to write to the 64bit keyset instead instead of its default of 32.
      • Im now trying to include a BAT Script in the K2000 Postinstallition Task.

        all i have in the BAT Script so far is:

        [hklm64\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]

        I need to call regedit or call reg? im not sure how to initiate the registry change in the BAT script.
      • sorry to confuse you, no that is how the kbox does it in the background for this type of script.
        if you want this to be bit independent you will need to create a cmd call script and

        use launch a program
        and use cmd.exe for the program
        use in the parameters
        /b c:\windows\sysnative\reg.exe /add HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon /v usrinit /d kusrinit /f

        sysnative forces the exe to call from the systems native directory vs the client calling from its native 32bit directory.
      • Im lost when it comes to creating BAT scripts. There is one in the K2000 that turns off UAC.
        reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA /t REG_DWORD /d 0 /f

        I dont need to add the key i need to modify an existing. I'm trying to locate the switch parameters listed and the purpose.
      • /f switch is force replacement so that is a modify. If you get stuck post new questions or if your script is sensitive use my email under my profile.

        Open a cmd window and do
        reg /?
        reg add /?
        reg delete /?
        for more help on using reg.exe in a batch file.

        pay attention to the key type, the default is reg_sz which is the most used data type in the registry.
      • I keep getting invalid syntax using the following in the cmd window.

        REG ADD HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon /v Usrinit /d C:\Windows\System32\KUsrInit.exe, /f
      • you have spaces so you need quotes.
        reg.exe add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon" /v Userinit /d "C:\Windows\system32\KUsrInit.exe," /f

        I will continue with your email you sent me
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ