mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Dec 2002
Posts: 580
N
Fjord artisan
OP Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 580
I know about WScript.Shell.{ RegRead | RegWrite | RegDelete }...

They are a good start, but I would like to be able to do this as well...

$regname(Key, n) - Lookup value names in a key
$regkey(Key, n) - Lookup subkey names in a key
$regKeyRename(Key Old, Key New) - Renames a key
$regKeyRemove(Key) - removes an entire key and all subkeys

Can anyone help me in the right direction?

Thanks,
Naquada

Joined: Dec 2002
Posts: 1,893
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,893
I've taken a trip to Usenet's archive and this is what I came up with...

1. This is not possible with Wscript (except "RegDelete" should remove subkeys in Win9x/Me).

2. To list subkeys or values of a key, the entire key contents must be extracted to a temporary file which you'll have to parse yourself. The command would be: regedit /e <file> <key>

3. To remove a key and its subkeys, create a REG file that will look like this:
  • REGEDIT4
    [-HKEY_LOCAL_MACHINE\Software\Test]
(notice the hyphen). Then merge the file to the registry: regedit /s <file.reg>

4. You don't "rename" keys, you create a new key, copy old contents and delete the old key. Regedit also works in this way. I don't know exactly how to do this one.

5. Once Khaled overcomes the COM dispatch issue it will be possible to download RegObj.dll, register it with /comreg, connect to its object - "RegObj.Registry", and use its various methods and properties. I have no idea about its usefulness anyway, but people mentioned it in their posts.

These are some alises I made according to suggestions brought to the newsgroups. They are quite slow, because each time you call them mIRC maintains a Wscript session, calls regedit and works with files, but I think that once you get the idea you can customize them and make them way efficient.
Code:
; $regval(Key, n) - Lookup value names in a key
; $regkey(Key, n) - Lookup subkey names in a key
; $regKeyRemove(Key) - removes an entire key and all subkeys
 
alias regval {
  if $2 == $null { echo missing param | return }
  .comopen x Wscript.Shell
  if $comerr { echo com error | return }
  var %file = regcache.tmp
  !.echo -q $com(x,Run,3,bstr,regedit /e %file $+(",$1,"),uint,0,bool,true)
  var %name = $ini(%file,$1,$2)
  .remove %file
  .comclose x
  return %name
}
 
alias regkey {
  if $2 == $null { echo missing param | return }
  .comopen x Wscript.Shell
  if $comerr { echo com error | return }
  var %file = regcache.tmp
  !.echo -q $com(x,Run,3,bstr,regedit /e %file $+(",$1,"),uint,0,bool,true)
  if $isfile(%file) {
    filter -ffcg %file %file $+(^\[,$replace($1,\,\\),\\[^\\]+\]$)
    if $2 == 0 { var %key = $lines(%file) }
    else var %key = $mid($read(%file,n,$2),2,-1)
    .remove %file
  }
  .comclose x
  return %key
}
 
alias regkeyremove {
  if !$1 { echo missing param | return }
  .comopen x Wscript.Shell
  if $comerr { echo com error | return }
  var %file = regremove.reg
  write %file $+(REGEDIT4,$lf,[-,$1])
  !.echo -q $com(x,Run,3,bstr,regedit /s %file,uint,0,bool,true)
  .comclose x
  .remove %file
  return 1
}

I hope this small research helped and welcome comments from everyone (yep qwerty, you too laugh).

Joined: Jan 2003
Posts: 2,125
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,125
Luckily there is a dll that works with mirc and provides complete access to the registry and that's DragonZap's registry.dll.

Joined: Dec 2002
Posts: 1,893
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,893
Loyal to its habit, the obvious answer once again slipped off my mind blush
Thanks q smile
The DLL is definitely better than those alises, but the enthusiasts of no-DLLs-whatsoever might like them.


Link Copied to Clipboard