Page 1 of 1

Read key from Windows registry

Posted: 20 Sep 2016 22:38
by rebr
Is there anyway to get the value at Windows Registry by SC?

I want to get:
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\{374DE290-123F-4565-9164-39C4925E467B}


Thanks in advance. :tup:

Re: Read key from Windows registry

Posted: 20 Sep 2016 22:41
by ds1508
You could use runret with a batch.
Pls have a look at http://stackoverflow.com/questions/4451 ... tch-script

Re: Read key from Windows registry

Posted: 20 Sep 2016 23:20
by highend
Probably the shortest version (only tested on a german system):

Code: Select all

    $k = quote("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders");
    $v = quote("{374DE290-123F-4565-9164-39C4925E467B}");

    $result = formatlist(gettoken(runret("REG QUERY $k /v $v"), 4, "    "), "e", <crlf>);
    text $result;
Put a question mark in front of "$result = ..." if you don't get the expected output to see what's going on...

Re: Read key from Windows registry

Posted: 21 Sep 2016 00:50
by rebr
highend wrote:Probably the shortest version (only tested on a german system):

Code: Select all

    $k = quote("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders");
    $v = quote("{374DE290-123F-4565-9164-39C4925E467B}");

    $result = formatlist(gettoken(runret("REG QUERY $k /v $v"), 4, "    "), "e", <crlf>);
    text $result;
Put a question mark in front of "$result = ..." if you don't get the expected output to see what's going on...
You genius! Worked awesome. Thanks a lot!

Re: Read key from Windows registry

Posted: 21 Sep 2016 00:51
by rebr
ds1508 wrote:You could use runret with a batch.
Pls have a look at http://stackoverflow.com/questions/4451 ... tch-script
Thanks for the north! :tup: