none
Bat File Logging RRS feed

  • General discussion

  • I have written a simple bat file to modify the Windows 7 x64 registry for purposes of locking down in a "ad-hoc" kiosk mode, and no I cannot use group policy...

    @Echo Off
    > c:\IT\Regedit.txt (

    REG ADD HKEY_CURRENT_USER\Software\Wow6432Node\Microsoft\Windows\Current_Version\Policies\System /v NoDispCPL /t REG_DWORD /d 1 /f
    REG ADD HKEY_CURRENT_USER\Software\Wow6432Node\Microsoft\Windows\Current_Version\Policies\Explorer /v NoSetTaskbar /t REG_DWORD /d 1 /f
    REG ADD HKEY_CURRENT_USER\Software\Wow6432Node\Microsoft\Windows\Current_Version\Policies\Explorer /v NoPropertiesMyComputer /t REG_DWORD /d 1 /f
    REG ADD HKEY_CURRENT_USER\Software\Wow6432Node\Microsoft\Windows\Current_Version\Policies\Explorer /v NoFolderOptions /t REG_DWORD /d 1 /f
    REG ADD HKEY_CURRENT_USER\Software\Wow6432Node\Microsoft\Windows\Current_Version\Policies\System /v DisableRegistryTools /t REG_DWORD /d 1 /f
    REG ADD HKEY_CURRENT_USER\Software\Wow6432Node\Microsoft\Windows\Current_Version\Policies\System /v DisableTaskMgr /t REG_DWORD /d 1 /f
    REG ADD HKEY_CURRENT_USER\Software\Wow6432Node\Microsoft\Windows\Current_Version\Policies\Explorer /v NoControlPanel /t REG_DWORD /d 1 /f
    REG ADD HKEY_CURRENT_USER\Software\Wow6432Node\Policies\Microsoft\Windows\System" /v DisableCMD /t REG_DWORD /d 2 /f

    I would like the log fil to output

    REG ADD NoDispCPL successful (or in-successful)

    REG ADD NoSetTaskbar successful (or in-successful)

    and so on.....

    Is this possible?


    DHeinz

    • Changed type Bill_Stewart Thursday, January 25, 2018 10:13 PM
    • Moved by Bill_Stewart Thursday, January 25, 2018 10:13 PM User should not be doing this
    Thursday, November 9, 2017 3:19 PM

All replies

  • Could you please format your code as code here in this forum? Thanks.
    Is this possible?
    Probably it would be possible but you would make your life much easier when you use Powershell for that purpose.

    Best regards (79,108,97,102|%{[char]$_})-join''

    Thursday, November 9, 2017 3:43 PM
  • Try redirecting the output.

    For example:

    REG ADD HKEY_CURRENT_USER\Software\Wow6432Node\Microsoft\Windows\Current_Version\Policies\System /v NoDispCPL /t REG_DWORD /d 1 /f >> C:\Temp\Output.txt

    Thursday, November 9, 2017 3:50 PM
  • That simply creates text saying completed successfully.

    I was looking to have it reference the reg key has completed successfully.

    ex: NoDispCPL has completed successfully


    DHeinz

    Thursday, November 9, 2017 5:49 PM
  • You would need to echo that yourself, since that's not in the output of the command.

    -- Bill Stewart [Bill_Stewart]

    Thursday, November 9, 2017 5:56 PM
  • I suggest using PowerShell as it is easier to manage logging.

    The following is much more manageable:

    $key = 'HKEY_CURRENT_USER\Software\Wow6432Node\Microsoft\Windows\Current_Version\Policies'
    function SetKioskMode{
        $updates = @(
            'Explorer /v NoSetTaskbar /t REG_DWORD /d 1 /f',
            'Explorer /v NoPropertiesMyComputer /t REG_DWORD /d 1 /f',
            'Explorer /v NoFolderOptions /t REG_DWORD /d 1 /f',
            'Explorer /v NoControlPanel /t REG_DWORD /d 1 /f',
            'System /v DisableRegistryTools /t REG_DWORD /d 1 /f',
            'System /v DisableTaskMgr /t REG_DWORD /d 1 /f',
            'System /v NoDispCPL /t REG_DWORD /d 1 /f'
        )
        foreach($update in $updates){
            $update
            REG ADD $key$update
            'Update completed'
        }
        $syskey = 'HKEY_CURRENT_USER\Software\Wow6432Node\Policies\Microsoft\Windows\System /v DisableCMD /t REG_DWORD /d 2 /f'
        $syskey
        REG ADD $sysKey
        'Update completed'
    }
    
    SetKioskMode > updates.log
    


    \_(ツ)_/

    Thursday, November 9, 2017 7:53 PM