0

Is there any batch command that will allow me to retrieve the value of the particular group policy in Windows server? Some thing like gpedit.msc did, but I want it in command line cause I want to convert those value to the format that I want.

Example: If I open gpedit.msc, then I navigate to Computer Configuration\Windows Settings\Security Settings\Local Policies\User Rights Assignment\Restore files and directories then I can get the value of this policy.

Any ways in batch scripting can get me to this path and capture the value?

Stephan
  • 53,940
  • 10
  • 58
  • 91
overshadow
  • 958
  • 2
  • 15
  • 31
  • `gpresult` gives all info on what is set (if absent not set to anything). It outputs normal command line (on multiple lines per entry - so useless), XML, and HTML. – Noodles Jul 08 '14 at 08:58
  • Oh I see, this one I can't customise the result to the format I need. Thanks you for your reply. – overshadow Jul 08 '14 at 09:04
  • I want something like REG.EXE QUERY HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\WdiSystemHost /V Start and I will get result like this HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\WdiSystemHost Start REG_DWORD 0x3 This one is just for registry, but I now I want group policy value. Thanks you. – overshadow Jul 08 '14 at 09:20

1 Answers1

0

It need debugging. This is searching for MemCheckBoxInRunDlg.

@echo off
setlocal enabledelayedexpansion
set flag=n
for /f "tokens=1 delims=" %%A in ('gpresult /z') do (
If !flag!==y echo %%A & set flag=n
Echo %%A |findstr /i /c:"memcheck">nul 2>&1
If errorlevel 0 if not errorlevel 1 set flag=y
) 
Noodles
  • 1,981
  • 1
  • 11
  • 4
  • Sorry for the late reply, I just tested the code. It doesn't work for me. I get this two line errors The syntax of the command is incorrect. The syntax of the command is incorrect. in command prompt. Thank you. – overshadow Jul 22 '14 at 09:42