kessler / node-regedit

Read, Write, List and do all sorts of funky stuff to the windows registry using node.js and windows script host
MIT License
277 stars 45 forks source link

REG_EXPAND_SZ not working properly for %USERPROFILE% #6

Closed ShaunMaher closed 9 years ago

ShaunMaher commented 9 years ago

Hi.

Apologies in advance if the problem here is me being a dumbass but, using the .list function to get values of type REG_EXPAND_SZ seems to expand the strings as if they were being expanded for the SYSTEM user.

I'm using your fine module to query values from HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders". In regedit these values all contain the place holder "%USERPROFILE%" which should be expanded to "C:\Users\MyUserName\" but are instead being expanded to "C:\Windows\system32\config\systemprofile\". I edited one of the values to give it a value with nothing to expand and it returned the expected value so I'm not accidentally querying the wrong user's HKCU. Running "SET" from the same command prompt that I am launching the node script from shows that the USERPROFILE environment variable is set correctly.

Here is my test script:

var windows_registry = require("regedit");

windows_registry.list('HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders').on('data', function(entry) {
    for (value in entry.data.values) {
        console.log(value + ": '" + entry.data.values[value].value + "'")
    }
}).on('finish', function() {
    console.log("finished getting reg entries");
});

and the result:

Desktop: 'C:\Windows\system32\config\systemprofile\Desktop'
Local AppData: 'C:\Windows\system32\config\systemprofile\AppData\Local'
Startup: 'C:\Windows\system32\config\systemprofile\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup'
Cookies: 'C:\Windows\system32\config\systemprofile\AppData\Local\Microsoft\Windows\INetCookies'
SendTo: 'C:\Windows\system32\config\systemprofile\AppData\Roaming\Microsoft\Windows\SendTo'
Personal: 'C:\Documents'
Recent: 'C:\Windows\system32\config\systemprofile\AppData\Roaming\Microsoft\Windows\Recent'
Favorites: 'C:\Windows\system32\config\systemprofile\Favorites'
My Pictures: 'C:\Windows\system32\config\systemprofile\Pictures'
Start Menu: 'C:\Windows\system32\config\systemprofile\AppData\Roaming\Microsoft\Windows\Start Menu'
NetHood: 'C:\Windows\system32\config\systemprofile\AppData\Roaming\Microsoft\Windows\Network Shortcuts'
My Music: 'C:\Windows\system32\config\systemprofile\Music'
My Video: 'C:\Windows\system32\config\systemprofile\Videos'
Cache: 'C:\Windows\system32\config\systemprofile\AppData\Local\Microsoft\Windows\INetCache'
Programs: 'C:\Windows\system32\config\systemprofile\AppData\Roaming\Microsoft\Windows\Start Menu\Programs'
History: 'C:\Windows\system32\config\systemprofile\AppData\Local\Microsoft\Windows\History'
{374DE290-123F-4565-9164-39C4925E467B}: 'C:\Windows\system32\config\systemprofile\Downloads'
Templates: 'C:\Windows\system32\config\systemprofile\AppData\Roaming\Microsoft\Windows\Templates'
AppData: 'C:\Windows\system32\config\systemprofile\AppData\Roaming'
PrintHood: 'C:\Windows\system32\config\systemprofile\AppData\Roaming\Microsoft\Windows\Printer Shortcuts'
finished getting reg entries

Let me know if there is any more information I can provide that would be helpful.

Cheers. Shaun.

kessler commented 9 years ago

Hi and thanks for reporting this.

I will looking into into shortly.

kessler commented 9 years ago

Hi @ShaunMaher

Can you run this little check for me?

In the window where you launch your node application, could you please run this command and reply with the output:

echo %userprofile%

Thanks

kessler commented 9 years ago

@ShaunMaher ping :)

kessler commented 9 years ago

@ShaunMaher Closing this issue for now.