New functions for handling the Registry

Apr 4, 2023 2 1196

Improving the reg function and adding a new reg.exists, reg.get, reg.set, reg.delete functions.

The first parameter, which is the root key, was combined with the subkey path into one parameter to be compatible with REG COMMANDS.

The keyname must include a valid root key. Valid root keys for the local computer are:

HKCU
HKCR
HKLM
HKU
HKEY_CLASSES_ROOT
HKEY_CURRENT_USER
HKEY_LOCAL_MACHINE
HKEY_USERS

REG.EXISTS

Check that the key name exists

reg.exists('HKCU\Control Panel\Desktop')

Check that the value name exists

reg.exists('HKCU\Control Panel\Desktop', "WallPaper")

REG.GET

Read data by value name

reg('HKCU\Control Panel\Desktop', "WallPaper")
reg.get('HKCU\Control Panel\Desktop', "WallPaper")
reg.get('HKCU\Control Panel\Desktop')

REG.SET

The reg.set function allows creating a subkey with the value name and value data

Create Subkey

reg.set('HKCU\Software\Nilesoft\Shell')

Create Subkey with value and set value data type

reg.set('HKCU\Software\Nilesoft\Shell', "test-int", 1, reg.dword)
reg.set('HKCU\Software\Nilesoft\Shell', "test-str", 1, reg.sz)
reg.set('HKCU\Software\Nilesoft\Shell', "test-str", 'some string', reg.sz)

Set value data with auto type detection

reg.set('HKCU\Software\Nilesoft\Shell', 'test-auto-int', 1)
reg.set('HKCU\Software\Nilesoft\Shell', 'test-auto-str', 'some string')

REG.DELETE

The reg.delete function allows deleting a subkey or deleting a value

Delete value name

reg.delete('HKCU\Software\Nilesoft\Shell', 'test-auto')

Delete subkey

reg.delete('HKCU\Software\Nilesoft\Shell')

2 Comments

Paddy
Sorry to be a pain and ask an unrelated question in the comments, but I'm so lost.

I'm a complete beginner with this stuff, so much so that I can't even get the "Hello World" thing to work 🤣

All I need is to be able to right-click a file, and select an option that will run a pre-defined renaming scheme on it. For example, replacing underscores with spaces.

Is that possible with this particular tool? If so, what would the code look like? And would I need special code so that the .ext isn't renamed? And would the code be even more different if I select multiple files to rename instead of just one? And is different code needed to deal with directory names? As you can see, I'm completely clueless.

Thanks for your help! And thank you for this tool, even without the particular function I need it's still a huge improvement over the standard shell menu. I can see me using this as a default install from here on.
Admin
Thank you Paddy for your interest

There are functions that can be used to rename files and folders as well.
See the following example where it provides a menu item that replacing underscores with spaces.

Add this code to dynamic section in the "shell.nss" file

item(title="Replacing underscores with spaces"
cmd=io.rename(sel.path, str.replace(sel.file,"_", " ")))

Save changes, Restart Explorer to apply new settings.

Comment format
  • **bold**
  • [[quote]]
  • [link title](https://site.com)
  • ![image title](https://site.com/image.png)
  • `code`
  • ```code block```