Hi!
I am trying to write a small script that cleans up the registry after starting Skype (which on regular basis registers itself in Run).
What I am looking now is the API of Win32::Registry. Where can I find it?
So far I have done this:
require 'win32/registry'
Run_branch = 'Software\Microsoft\Windows\CurrentVersion\Run'
Skype_key = 'Skype'
Win32::Registry::HKEY_CURRENT_USER.open(Run_branch, Win32::Registry::Constants::KEY_ALL_ACCESS) do |
reg |
reg_typ, reg_val = reg.read(Skype_key)
puts "type: #{reg_typ}"
puts "val : #{reg_val}"
end
type: 1
val : "C:\Program Files\Skype\Phone\Skype.exe" /nosplash /minimized
As you can see I was able to identify the key, but I don't know what can I do next. Win32::Registry doesn't seem to have a method to delete or modify the content of the key.
On a more general note usually when you want to use such an extension where should I look for documentation?
thanks a lot,
./alex
···
--
.the_mindstorm.
Alexandru Popescu wrote:
Hi!
I am trying to write a small script that cleans up the registry after starting Skype (which on
regular basis registers itself in Run).
What I am looking now is the API of Win32::Registry. Where can I find it?
So far I have done this:
require 'win32/registry'
Run_branch = 'Software\Microsoft\Windows\CurrentVersion\Run'
Skype_key = 'Skype'
Win32::Registry::HKEY_CURRENT_USER.open(Run_branch, Win32::Registry::Constants::KEY_ALL_ACCESS) do |
> reg |
reg_typ, reg_val = reg.read(Skype_key)
puts "type: #{reg_typ}"
puts "val : #{reg_val}"
If you haven't built, or don't have an install of, the rdoc
documentation for Ruby, you can find it at
http://www.ruby-doc.org/stdlib/
Modifying and deleting is fairly easy, IIRC:
reg[Skype_key] = "new value"
reg.delete_key(Skype_key)
Cheers,
- alan
#: Alan Chen changed the world a bit at a time by saying on 9/29/2005 12:46 AM :#
Alexandru Popescu wrote:
Hi!
I am trying to write a small script that cleans up the registry after starting Skype (which on
regular basis registers itself in Run).
What I am looking now is the API of Win32::Registry. Where can I find it?
So far I have done this:
require 'win32/registry'
Run_branch = 'Software\Microsoft\Windows\CurrentVersion\Run'
Skype_key = 'Skype'
Win32::Registry::HKEY_CURRENT_USER.open(Run_branch, Win32::Registry::Constants::KEY_ALL_ACCESS) do |
> reg |
reg_typ, reg_val = reg.read(Skype_key)
puts "type: #{reg_typ}"
puts "val : #{reg_val}"
If you haven't built, or don't have an install of, the rdoc
documentation for Ruby, you can find it at
RDoc Documentation
Modifying and deleting is fairly easy, IIRC:
reg[Skype_key] = "new value"
reg.delete_key(Skype_key)
Cheers,
- alan
delete_key results in error:
Win32::Registry::Error: The system cannot find the file specified.
from c:/ruby/ruby-1.8.2-15/lib/ruby/1.8/win32/registry.rb:800:in `delete_key'
from (irb):6
from (irb):5:in `open'
from c:/ruby/ruby-1.8.2-15/lib/ruby/1.8/win32/registry.rb:608:in `open'
from (irb):5
./alex
···
--
.the_mindstorm.
daz
(daz)
29 September 2005 04:36
4
Alexandru Popescu wrote:
>>
>> What I am looking now is the API of Win32::Registry. Where can I find it?
>>
The first 260 lines of registry.rb is an rdoc description
although I couldn't find an entry on ruby-doc.
Readable enough though.
delete_key results in error:
You want delete_value(Skype_key) # (alias delete)
Your key is 'Run' ... 'Run' can have multiple values ...
.... each value can have data associated with it.
So, one 'Run' value is 'Skype' which has data of "C:\...Skype.exe...".
Terminology/apology (skip the WMI stuff):
http://www.microsoft.com/technet/scriptcenter/resources/qanda/mar05/hey0304.mspx
Whatever; I call 'Skype' a key and the data its value because
'[key] = value' fits better than '[value] = data', in my head.
daz
daz wrote:
Alexandru Popescu wrote:
What I am looking now is the API of Win32::Registry. Where can I find it?
The first 260 lines of registry.rb is an rdoc description
although I couldn't find an entry on ruby-doc.
http://www.ruby-doc.org/stdlib/libdoc/Win32API/rdoc/files/Win32API/lib/win32/registry_rb.html
http://www.ruby-doc.org/stdlib/libdoc/Win32API/rdoc/classes/Win32/Registry/API.html
James
···
--
http://www.ruby-doc.org - The Ruby Documentation Site
http://www.rubyxml.com - News, Articles, and Listings for Ruby & XML
http://www.rubystuff.com - The Ruby Store for Ruby Stuff
http://www.jamesbritt.com - Playing with Better Toys
Yep, usually I am using the same terms, but it seems once again that
MS is smarter :-).
./alex
···
--
.the_mindstorm.
On 9/29/05, daz <dooby@d10.karoo.co.uk> wrote:
Alexandru Popescu wrote:
> >>
> >> What I am looking now is the API of Win32::Registry. Where can I find it?
> >>
The first 260 lines of registry.rb is an rdoc description
although I couldn't find an entry on ruby-doc.
Readable enough though.
>
> delete_key results in error:
>
You want delete_value(Skype_key) # (alias delete)
Your key is 'Run' ... 'Run' can have multiple values ...
.... each value can have data associated with it.
So, one 'Run' value is 'Skype' which has data of "C:\...Skype.exe...".
Terminology/apology (skip the WMI stuff):
http://www.microsoft.com/technet/scriptcenter/resources/qanda/mar05/hey0304.mspx
Whatever; I call 'Skype' a key and the data its value because
'[key] = value' fits better than '[value] = data', in my head.
daz