none
Trying to modify registry in 1703 where it worked in 1607. RRS feed

  • Question

  • I have a batch file which makes reg changes for 3G and 4G for Outlook. (It prompts users that they may be on a metered connection and charged extra).
    In 1607 I copy a batch file to a folder on C: and then a CMD to run it. It changes ownership of the reg key, makes the change, and returns ownership to TrustedInstaller.

    It fails to run on 1703. I can copy it to C:\ but then it fails to run. Below is the file:

    Reg Query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\DefaultMediaCost" /v 3G
    If %ERRORLEVEL% GEQ 1 GOTO 4G

    :SETUP ACL FOR 3G
    SetACL -on "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\DefaultMediaCost" -ot reg -actn setowner -ownr "n:Administrators"

    SetACL -on "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\DefaultMediaCost" -ot reg -actn ace -ace "n:Administrators;p:full"

    SetACL -on "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\DefaultMediaCost" -ot reg -actn setowner -ownr "n:NT Service\TrustedInstaller"

    SetACL -on "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\DefaultMediaCost" -ot reg -actn ace -ace "n:NT Service\TrustedInstaller;p:full"

    reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\NetworkList\DefaultMediaCost" /v 3G /t REG_DWORD /d 1 /f

    :SETUP ACL FOR 4G

    :4G
    Reg Query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\DefaultMediaCost" /v 4G
    If %ERRORLEVEL% GEQ 1 GOTO END

    SetACL -on "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\DefaultMediaCost" -ot reg -actn setowner -ownr "n:Administrators"

    SetACL -on "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\DefaultMediaCost" -ot reg -actn ace -ace "n:Administrators;p:full"

    SetACL -on "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\DefaultMediaCost" -ot reg -actn setowner -ownr "n:NT Service\TrustedInstaller"

    SetACL -on "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\DefaultMediaCost" -ot reg -actn ace -ace "n:NT Service\TrustedInstaller;p:full"

    reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\NetworkList\DefaultMediaCost" /v 4G /t REG_DWORD /d 1 /f

    :END
    ***********
    Here is the CMD I use to run it:
    cmd /c C:\Fixes\OutlookMeterFix\SETACL.bat

    The error is Incorrect Function. 2147467259

    Thursday, September 7, 2017 8:45 PM

All replies

  • What happens when you run the script manually?

    Cheers,
    Anton

    Vacuum Breather Blog | Wing Commander Saga | Twitter

    Note: Posts are provided "AS IS" without warranty of any kind. If posts are helpful please don't forget to rate them as "Helpful" or as "Answer".

    Friday, September 8, 2017 12:09 PM
  • When I ran it manually in 1607 a DOS box would appear and the text would scroll endlessly and never complete the task. Running it through MDT caused the registry entries to change as desired.

    Running it in 1703 manually causes the same...a DOS box that runs endlessly.
    The error I get running the CMD in 1703 in MDT gives the error above:
    The error is Incorrect Function. 2147467259

    I see the registry structure is identical in both OS's.

    Friday, September 8, 2017 12:27 PM
  • I would start troubleshooting by running the script from an elevated command prompt thus allowing you to capture the output.

    Cheers,
    Anton

    Vacuum Breather Blog | Wing Commander Saga | Twitter

    Note: Posts are provided "AS IS" without warranty of any kind. If posts are helpful please don't forget to rate them as "Helpful" or as "Answer".

    Friday, September 8, 2017 3:53 PM
  • Its not a CMD, its a batch file. I guess I could possibly try adding the batch file to my scripts folder and adding a TS step to kick it off.

    Running it as admin (right-click) just causes a split-second flash and it is gone.
    Running it just by clicking it causes the endless loop in the DOS box.

    Friday, September 8, 2017 4:19 PM
  • You can run batch scripts from a command prompt.

    Cheers,
    Anton

    Vacuum Breather Blog | Wing Commander Saga | Twitter

    Note: Posts are provided "AS IS" without warranty of any kind. If posts are helpful please don't forget to rate them as "Helpful" or as "Answer".

    Friday, September 8, 2017 4:23 PM
  • Currently, in 1607, I have one short task which copies the batch file to the target C:. Then I have a CMD added to kick off that batch file. It does work in 1607.

    I get the initial error in 1703. I'm going to try it from the server\scriptroot folder this time.

    Friday, September 8, 2017 4:26 PM
  • It‘s your call. :-) I am just saying that in order to troubleshoot your issue you need to capture the output of your script. You could do that by running the script from an elevated cmd manually or by piping the output of your commands into a text file. You might also want to consider moving to PowerShell at some point.

    Cheers,
    Anton

    Vacuum Breather Blog | Wing Commander Saga | Twitter

    Note: Posts are provided "AS IS" without warranty of any kind. If posts are helpful please don't forget to rate them as "Helpful" or as "Answer".

    Friday, September 8, 2017 4:36 PM
  • I'm lucky to have known how to run the batch file in 1607 and have it work. Its just a plain text with a changed extension. Creating a PS in place is beyond what I know, as well as adding logging for it.
    Friday, September 8, 2017 5:07 PM