@regsetenv complains "wrong parameter"

I am trying to do this:
set %sink= %@regsetenv["HKLM_64\SOFTWARE\Microsoft\Windows\CurrentVersion\MMDevices\Audio\Render\{2bbfe435-eb75-4c25-96ff-ef430f8d568e}\DeviceState",REG_DWORD,1]

and get an error message "wrong parameter":
TCC: (Sys) Falscher Parameter.
"%@regsetenv[REG_DWORD,1]"

What's the problem?
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,200
72
Albuquerque, NM
prospero.unm.edu
You'll get that error message if the key you're trying to write to doesn't exist. Use @REGCREATE to create it first; or test with @REGEXIST and skip if you don't want to write to a nonexistent key.

I don't know why the second line of the error message omits the value name. That may be a bug.
 

samintz

Scott Mintz
May 20, 2008
1,413
13
Solon, OH, USA
Also, if you typed the command as you have written it, then it should be 'set sink=%@reg...' I.e. remove the % before sink and the space after the =.
 
Thanks for the swift replies. The regkey does exist:
echo %@regexist["HKLM_64\SOFTWARE\Microsoft\Windows\CurrentVersion\MMDevices\Audio\Render\{2bbfe435-eb75-4c25-96ff-ef430f8d568e}"]
1
However, the modified command does not cut it:
set sink=%@regsetenv["HKLM_64\SOFTWARE\Microsoft\Windows\CurrentVersion\MMDevices\Audio\Render\{2bbfe435-eb75-4c25-96ff-ef430f8d568e}\DeviceState","REG_DWORD",2]
TCC: (Sys) Falscher Parameter.
"%@regsetenv["REG_DWORD",2]"
 
May 20, 2008
10,563
78
Syracuse, NY, USA
I can reproduce a similar error (elevated, with or without using "_64").
Code:
c:\apps\workplace> regdir HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\MMDevices\Audio\Render\{0d297c76-53b6-4676-baac-ef9f24533877}
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\MMDevices\Audio\Render\{0d297c76-53b6-4676-baac-ef9f24533877}
  Properties

c:\apps\workplace> echo %@regsetenv["HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\MMDevices\Audio\Render\{0d297c76-53b6-4676-baac-ef9f24533877}\foo",REG_DWORD,2]
TCC: (Sys) The parameter is incorrect.
 "%@regsetenv[REG_DWORD,2]"
Note that, here, Users and Administrators have READ_ONLY access to the key above.
 
May 20, 2008
10,563
78
Syracuse, NY, USA
@REGSETENV does give a rather cryptic error message. When I try the code below, I get ERROR_ACCESS_DENIED ("Access is denied").
Code:
    HKEY hKey;
    LONG foo = RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\MMDevices", 0, KEY_SET_VALUE, &hKey);
    Error(L"MMDevices", foo);
 
Aug 23, 2010
581
7
set sink=%@regsetenv["HKLM_64\SOFTWARE\Microsoft\Windows\CurrentVersion\MMDevices\Audio\Render\{2bbfe435-eb75-4c25-96ff-ef430f8d568e}\DeviceState","REG_DWORD",2]
TCC: (Sys) Falscher Parameter.
"%@regsetenv["REG_DWORD",2]"
This is "informational only" parameter. You can't achieve anything even if you change it.
 
May 20, 2008
10,563
78
Syracuse, NY, USA
@vefatica: I can change the value with regedit, so shouldn't TC then be able to do the same.

@AnrDaemon: not true. This (and another key) will be used to switch audio-devices.
I don't know. I only reported what I saw. In REGEDIT right=click on the key and look at "Permissions...". In my own EXE, when I try to open MMDevices with write access, even elecated, I get "Access denied". The subkeys inherit the permissions.
 
May 20, 2008
10,563
78
Syracuse, NY, USA
Hmmm. I don't think I tested my test app elevated properly yesterday. Today, My app (rather ordinary) run elevated can set values in the MMDevices key. So an elevated TCC should be able to do it. @REGSETENV and @REGSET both behave a litle screwy. With correct syntax (?) they give the cryptic error you mentioned; with bad syntax they return 0 but don't set the value!

I believe this is correct syntax.
Code:
c:\apps\workplace> echo %@regsetenv["HKLM\SOFTWARE\JPSoftware\foo",REG_DWORD,22]
TCC: (Sys) The parameter is incorrect.
 "%@regsetenv[REG_DWORD,22]"
And I think this is bad syntax; it does not set the value:
Code:
c:\apps\workplace> echo %@regsetenv["HKLM\SOFTWARE\JPSoftware",foo,REG_DWORD,22]
0
 
May 20, 2008
10,563
78
Syracuse, NY, USA
When I look more closely at the premissions on MMDevices, I see this.

2336


That says admins can SET VALUE and it agrees with the output of SUBINACL.EXE.
Code:
/pace =builtin\administrators     ACCESS_ALLOWED_ACE_TYPE-0x0
    CONTAINER_INHERIT_ACE-0x2      
    Key and SubKey - Type of Access:
    Special acccess : -Query Value -Set Value -Enumerate Subkeys -Notify-Read Control 
    Detailed Access Flags :
    KEY_QUERY_VALUE-0x1        KEY_SET_VALUE-0x2          KEY_ENUMERATE_SUB_KEYS-0x8 
    KEY_NOTIFY-0x10            READ_CONTROL-0x20000[/code/
 
May 20, 2008
10,563
78
Syracuse, NY, USA
Hmmm. I don't think I tested my test app elevated properly yesterday. Today, My app (rather ordinary) run elevated can set values in the MMDevices key. So an elevated TCC should be able to do it. @REGSETENV and @REGSET both behave a litle screwy. With correct syntax (?) they give the cryptic error you mentioned; with bad syntax they return 0 but don't set the value!

I believe this is correct syntax.
Code:
c:\apps\workplace> echo %@regsetenv["HKLM\SOFTWARE\JPSoftware\foo",REG_DWORD,22]
TCC: (Sys) The parameter is incorrect.
"%@regsetenv[REG_DWORD,22]"
And I think this is bad syntax; it does not set the value:
Code:
c:\apps\workplace> echo %@regsetenv["HKLM\SOFTWARE\JPSoftware",foo,REG_DWORD,22]
0
Actually, that works when I spell it correctly.
Code:
c:\apps\workplace> echo %@regquery["HKLM\SOFTWARE\JP Software\foo"]
25

c:\apps\workplace> echo %@regsetenv["HKLM\SOFTWARE\JP Software\foo",REG_DWORD,19]
0

c:\apps\workplace> echo %@regquery["HKLM\SOFTWARE\JP Software\foo"]
19
 
May 20, 2008
10,563
78
Syracuse, NY, USA
I think there are two things wrong. According to ProcessMonitor when TCC does
Code:
echo %@regset["HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\MMDevices\FOO",reg_dword,25]
this happens:

2337


TCC is apparently asking for KEY_WRITE access to the key. KEY_WRITE is a combination of STANDARD_RIGHTS_WRITE (a.k.a. READ_CONTROL), KEY_SET_VALUE, and KEY_CREATE_SUB_KEY. It fails because the elevated TCC does not have permission for KEY_CREATE_SUB_KEY (which is not needed if you're setting a value). All you need to set a value is KEY_SET_VALUE. Note that an admin trying to create a subkey also fails in REGEDIT.

And then there's the peculiar error message.
 
Thread starter Similar threads Forum Replies Date
C Support 2
Joe Caverly Support 7