How I could add Additional Rules in Software Restriction Policies with cmd using a script that'll work with both Windows 7 and Windows Vista.

I would like to create some path rules with security level set to "Disallowed".

Below are a few lines I'd like to incorporate into this script:

C:\Documents and Settings\%username%\Local Settings\Application Data\Google\Chrome\Application\chrome.exe

So you need to way to disallow certain executable files from being run for each user signed onto a PC for Windows 7 and/or Windows Vista, and you need to implement it via CMD fashion to apply locally at the machine level.

Instructions and Detail

See How to Block an Application or .EXE from Running in Windows and from some information as listed there, I've created the below batch script that can be run to "Disallow" these executables from being executed from that user account.

If you need to scale this CMD method to add further executable file names than the four you provided, you simply move up sequentially to the next number and then plug in the executable name as in the below example for instance:

ECHO "3"="Gears-chrome-opt.msi"              >> "%TmpRegFile%"
ECHO "4"="GoogleUpdate.exe"                  >> "%TmpRegFile%"
ECHO "5"="App5toBlock.exe"                   >> "%TmpRegFile%"
ECHO "6"="App6toBlock.msi"                   >> "%TmpRegFile%"

See How to Block an Application or .EXE from Running in Windows for further explanation.

You might consider testing and replacing HKEY_CURRENT_USER with HKEY_LOCAL_MACHINE in the below script to lock down disallowing these executable files from being run at the entire PC level rather than the user account that's signed on when the script is run.

You may also need to run the batch script as an administrator as well or the REG IMPORT command could get an access denied message when it tries to update the registry. You can copy and paste all of the below into CMD directly as well but don't paste in the last line of EXIT /B so the screen buffer text stays up.

Batch Script

I used TASKKILL commands in the below script to forcefully kill all instances of the same executable file names to disallow with the registry import. If any are running in memory on the machine when this runs then they will be killed; scale applicable logic as needed to add further processes to kill.

The Windows Explorer Shell needs to be killed and restarted in memory before these settings become effective. Doing a complete power cycle of the machine would do the trick, and potentially logging on and right back on may work. I used WMIC to refresh Windows Explorer with a WHERE clause and CALLing TERMINATE as it restarts it.


SET TmpRegFile=%temp%\~DisallowExe.reg
IF EXIST "%TmpRegFile%" DEL /Q /F "%TmpRegFile%"

ECHO Windows Registry Editor Version 5.00  >> "%TmpRegFile%"
ECHO.                                      >> "%TmpRegFile%"
ECHO [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer]             >> "%TmpRegFile%"
ECHO "DisallowRun"=dword:00000001                                                                >> "%TmpRegFile%"
ECHO [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\DisallowRun] >> "%TmpRegFile%"
ECHO "1"="Chrome.exe"                        >> "%TmpRegFile%"
ECHO "2"="chrome_installer.exe"              >> "%TmpRegFile%"
ECHO "3"="Gears-chrome-opt.msi"              >> "%TmpRegFile%"
ECHO "4"="GoogleUpdate.exe"                  >> "%TmpRegFile%"

TASKKILL /F /IM "Chrome.exe"
TASKKILL /F /IM "chrome_installer.exe"
TASKKILL /F /IM "Gears-chrome-opt.msi"
TASKKILL /F /IM "GoogleUpdate.exe"

REG IMPORT "%TmpRegFile%"
PING -n 05 > nil
WMIC PROCESS WHERE "Caption = 'explorer.exe'" CALL TERMINATE


Further Resources

| improve this answer | |
  • Seems like script added values t oreg but those values don't work, I still can launch chrome.exe , any ideas why ?(while using local machine) – marcius jodeika Jul 15 '16 at 10:54
  • Guys, sorry to interrupt. Maybe I'm wrong (because I'm testing on Windows 10) but it actually stores registry keys in this path: HKLM\Software\Microsoft\Windows\safer and in a style not easy to imitate. I understand you are actually setting an execution ban, but he asked for a software restriction path rule?! – NetwOrchestration Jul 17 '16 at 10:57
  • intresting. I still can run chrome after added registers . s32.postimg.org/qa0kwytat/11004397871143533672.jpg – marcius jodeika Jul 18 '16 at 5:18
  • P.S. I need to make this all in local machine to prevent multiple users from using chrome some are on domain, but I can't modify domain with registers – marcius jodeika Jul 18 '16 at 7:34
  • yes, but as I said i prefer making on local machine – marcius jodeika Jul 18 '16 at 10:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.