Trying to edit the registry in Windows with a batch file

37,775

Looks to me like you have the Registry value name and data swapped. According to the kb article, the REG_SZ value(s) should be named numerically starting with "1", and the included data would be the executable name ("msnmsgr.exe"). Thus, your .REG file should look like this:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\DisallowRun]
"1"="msnmsgr.exe"

Also, I would recommend that you use the REG.EXE program for simple edits like this, rather than importing a .REG file. For the change you wanted, your REG.EXE command would look like this:

reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\DisallowRun" /v "1" /t REG_SZ /d "msnmsgr.exe" /f
Share:
37,775
Kevin
Author by

Kevin

Updated on July 24, 2022

Comments

  • Kevin
    Kevin almost 2 years

    I am supporting a few offices across the country running Windows XP. They are stand alone, no Windows Server or Active Directory, anything like that. I just switched them over to Google Apps, and in the process replaced Windows Live Messenger with Google Talk. I really want to stop Windows Live from being used, the platform sends so much spam and seems to have a lot of holes. I have tested making a registry edit to key

    HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\DisallowRun 
    

    adding a string value msnmsgr.exe set to 1. I did it manually on one machine, and it worked, under both profiles, it wouldn't start Messenger. After my success, I wrote a .REG file thusly:

    Windows Registry Editor Version 5.00
    
    [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\DisallowRun]
    "msnmsgr.exe"="1"
    

    And a batch file, run from the same directory, written like this:

    @ECHO off
    
    REGEDIT.EXE /S msn.reg
    

    It seems to write to the registry, but Live is starting. No idea what's happening. Seems this could have gone either way between Serverfault and here, but I went here since the Administration part seems resolved yet the little programming involved isn't working out.

    Thanks in advance for any assistance.

  • Kevin
    Kevin over 13 years
    I am sorry, I meant HKEY_CURRENT_USER.
  • ewall
    ewall over 13 years
    (Edited original question for HKCU.)
  • Kevin
    Kevin over 13 years
    The files are exactly the same
  • Kevin
    Kevin over 13 years
    And I would place that line in a batch file?
  • ewall
    ewall over 13 years
    Yes, exactly. The reg add ... command should work directly on the command-line or in a batch script.
  • Nagarajan S R
    Nagarajan S R over 8 years
    Hi, I tried and it did work. My question is how to disable the prompt confirming to add registry?
  • Stony
    Stony over 6 years
    There will be no prompt if you use the /f switch. technet.microsoft.com/en-us/library/cc742162(v=ws.10).aspx