Registry Entries

nnCron and nnCron LITE discussion

Registry Entries

Postby Frank » Sat, 31 May 2008, 03:45

I have a registry entry question. I tried to test for the existence of a registry key entry:

Action:
ShowNormal NormalPriority
S" HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\hmonitor" REG-KEY-EXIST?
IF
HINT: "Found Hmonitor entry"
REG-DELETE-VALUE: "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\hmonitor"
THEN

The reason I need to test for the hmonitor value (which is "C:\Program Files\Hmonitor\hmonitor.exe") is that if I try to delete this value without it existing nnCron gives an error. The run key always exists, hmonitor is a value name. So I understand why this does not work. But, how do I check for the existence of the hmonitor value name?
Thanks
Frank
Frank
 
Posts: 30
Joined: Sun, 02 Apr 2006, 09:18

Re: Registry Entries

Postby Frank » Tue, 03 Jun 2008, 03:13

There have not been any replies to this post for a few days.
I have been trying to solve the problem.

My latest attempt is:
: Reg_key_delete REG-DELETE-VALUE: "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\hmonitor" ;
Action:
ShowNormal NormalPriority
['] Reg_key_delete CATCH ?DUP

What I am trying to do here is to catch an error if created by the key not existing. This way I could use this command and delete the key if it exists without errors being displayed.
Unfortunately, this gives me a error - Action: Stack error.
I don't know what the ?DUP means and I can't find it in the help file. I found examples of its use but no explanation as to what it is or does. I used the examples to write the above.
Could someone please let me know where i am wrong.
Frank
Frank
 
Posts: 30
Joined: Sun, 02 Apr 2006, 09:18

Re: Registry Entries

Postby Valery_Kondakoff » Tue, 03 Jun 2008, 12:35

As far as I understand, the REG-KEY-EXIST? word does not work just because it is expecting to see the registry key ( like "Microsoft\Windows\CurrentVersion\Run" ), not the parameter ("hmonitor").

You may tray to use GET-REG: instead and then comapare the recieved value to hmonitor path ( http://www.nncron.ru/help/EN/add_info/f ... tr_compare ).

HTH!
CU
VK
User avatar
Valery_Kondakoff
Site Admin
 
Posts: 769
Joined: Thu, 01 Jul 2004, 20:49
Location: Moscow, Russia

Re: Registry Entries

Postby Valery_Kondakoff » Tue, 03 Jun 2008, 13:50

Nicholas created a special words to check registry values instead of keys. Use it like this:

Code: Select all
#( test_frank
NoActive
 : REG-VALUE-EXIST? ( a u -- ?)
    1024 ALLOCATE THROW DUP >R ROT ROT
    [NONAME GET-REG NONAME] CATCH IF 2DROP DROP FALSE ELSE TRUE THEN
    R> FREE DROP
;
Action:
S" HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\ShStatEXE" REG-VALUE-EXIST?
IF
    MSG: "Yes!"
ELSE
    MSG: "No!"
THEN
)#
CU
VK
User avatar
Valery_Kondakoff
Site Admin
 
Posts: 769
Joined: Thu, 01 Jul 2004, 20:49
Location: Moscow, Russia

Re: Registry Entries

Postby Frank » Wed, 04 Jun 2008, 02:44

Thank you Velery.
Thank works very well.
A special thatnk you to Nicholas also.
I am sorry about the my lack of knowledge about the programming side. I did a lot of programming in various Basic languages, some C, some HTML and mostly nowdays I use TCL/TK. I used reverse polish notation calulators before and had no trouble. However, for some reason,I do find problems undertanding Forth (even just following it). Just the way I think, I guess. I'll keep trying.
Frank
Frank
 
Posts: 30
Joined: Sun, 02 Apr 2006, 09:18


Return to nnCron forum (English)

Who is online

Users browsing this forum: No registered users and 0 guests