@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,469
88
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,503
16
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
11,432
99
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
11,432
99
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
637
9
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
11,432
99
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
11,432
99
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
11,432
99
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
11,432
99
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
11,432
99
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.
 
Similar threads
Thread starter Title Forum Replies Date
vefatica @REGSETENV not broadcasting message? Support 2
Joe Caverly @REGSETENV question Support 7
C Trend Micro complains about malware for 14.03.51 Support 2
JohnQSmith New online help file wrong logo Support 7
vefatica @EXECSTR ... TCSTART ... something's wrong! Support 7
R History window wrong size, can't remember size change Support 12
mfarah Fixed The DATE command produces the wrong error message. Support 1
mikea How to? TCC registered to wrong 'entity' Support 5
T @replace -- what is wrong here Support 2
vefatica Fixed KEYSTACK /i with repeat count sends wrong keys Support 7
C ZIP/U compares wrong timestamp Support 13
vefatica @WORDS, often wrong Support 0
vefatica gcd() ... wrong answer, lcm() hangs Support 5
D What is wrong with this code? Support 7
vefatica WAD DIR /HL still gets names wrong Support 16
H Fixed DIR /G returns wrong sizes Support 2
M Another "What is wrong?" Support 8
M What is wrong with this command? Support 4
vefatica Updater says wrong version Support 1
CWBillow Wrong icons keep sticking Support 6
M How to? What am I doing wrong/not understanding? Support 10
C News link wrong Support 1
M What am I doing wrong? Support 12
M What am I doing wrong here? Support 2
C Forum column headings wrong? Support 4
gschizas Installation folder for TCMD x64 15.1 is wrong Support 5
Dan Glynhampton Documentation v15 help: ECHOXERR Help Page Title is Wrong Support 0
M What am I doing wrong in this (very simple!) code? Support 3
vefatica Something wrong with @PID Support 10
J zip wrong central directory signature Support 12
S Fixed _DO_FILES and _DO_DIRS wrong Support 0
B Downloading Updates - Error: Wrong file size?? Support 3
vefatica What's wrong here? Support 2
vefatica Wrong startup file? Support 1
M How to? Missing closing quote: What am I doing wrong???? Support 7
gschizas (minor) Help topic "Colors, Color Names and Codes" is wrong Support 0
T Wrong prompt in Windows command console Support 3
M Where am I going wrong with ALIAS??? Support 7
G Wrong File Size Support 8
vefatica Updating v10: error wrong file size Support 2
S Wrong .INI file used by TCC Support 2
K_Meinhard Wrong sender adress Support 0

Similar threads