Test registry Key availability

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
giovanniroi
Junior Coder
Posts: 21
Joined: Fri Jul 03, 2009 4:36 pm
Location: Milan,Italy

Test registry Key availability

Post by giovanniroi » Tue Oct 09, 2012 1:42 pm

Dear Support,
I use this code to write a windows registry key:
RegistryWriteKey>HKEY_CURRENT_USER,Software\Microsoft\Office\12.0\Access\Security\Trusted Locations\Location0,Path,C:\GR&A_Trend\
REG_INTASSTR = 1
RegistryWriteKey>HKEY_CURRENT_USER,Software\Microsoft\Office\12.0\Access\Security\Trusted Locations\Location0,AllowSubfolders,1

What is the code that I need to use to test the availability of this Key in the Windows registry?

Thank's

Giovanni Roi

Jerry Thomas
Macro Veteran
Posts: 267
Joined: Mon Sep 27, 2010 8:57 pm
Location: Seattle, WA

Post by Jerry Thomas » Tue Oct 09, 2012 2:51 pm

Sample from the Help documentation...

RegistryReadKey>HKEY_CURRENT_USER,Control Panel\Colors,ActiveTitle,VActTitle
Thanks,
Jerry

[email protected]

giovanniroi
Junior Coder
Posts: 21
Joined: Fri Jul 03, 2009 4:36 pm
Location: Milan,Italy

Post by giovanniroi » Thu Oct 18, 2012 2:51 pm

Dear Jerry,
I try to use the standard functionalyty but this don't Work well.

I use this code:
=========
RegistryReadKey>HKEY_CURRENT_USER,Software\Microsoft\Office\12.0\Access\Security\Trusted Locations\Location0,Path,C:\GR&A_Trend\,VActTitle
IF>VActTitle=C:\GR&A_Trend\
MessageModal>Chiave OK
else
RegistryWriteKey>HKEY_CURRENT_USER,Software\Microsoft\Office\12.0\Access\Security\Trusted Locations\Location0,Path,C:\GR&A_Trend\
ENDIF
========
but running the code Macro Scheduler go anyway in "else" option of the "if"test, also if the registry Key is available.

How can I solve this problem?

Thank's for the support

Giovanni Roi

Jerry Thomas
Macro Veteran
Posts: 267
Joined: Mon Sep 27, 2010 8:57 pm
Location: Seattle, WA

Post by Jerry Thomas » Thu Oct 18, 2012 3:04 pm

You have too many parameters

RegistryReadKey>HKEY_CURRENT_USER,Software\Microsoft\Office\12.0\Access\Security\Trusted Locations\Location0,Path,C:\GR&A_Trend\,VActTitle

RegistryReadKey>root_key,key,entry,result_variable
root_key = HKEY_CURRENT_USER
key = Software\Microsoft\...
entry = Path
??? = C:\GR&A_Trend
result_variable = VActTitle
Thanks,
Jerry

[email protected]

giovanniroi
Junior Coder
Posts: 21
Joined: Fri Jul 03, 2009 4:36 pm
Location: Milan,Italy

Post by giovanniroi » Sat Oct 20, 2012 5:24 pm

Dear Jerry,
the problem that I find in the Registry Key read is for all the Registry Key that You cal try to read.
In my case i have:
Root: HKEY_CURRENT_USER,Software\Microsoft\Office\12.0\Access\Security\Trusted Locations\Location0
Key:Path
Content of the Key: C:\GR&A_Trend\
thne the code is:
=======
RegistryReadKey>HKEY_CURRENT_USER,Software\Microsoft\Office\12.0\Access\Security\Trusted Locations\Location0,Path,C:\GR&A_Trend\,VActTitle
IF>VActTitle=C:\GR&A_Trend\
MessageModal>Chiave OK
else
RegistryWriteKey>HKEY_CURRENT_USER,Software\Microsoft\Office\12.0\Access\Security\Trusted Locations\Location0,Path,C:\GR&A_Trend\
ENDIF
==========
When I execute step-by-step this code in Macro Scheduler in the Whatct list the system swh this code:
"0: C:\GR&A_TREND\,VACTTITLE=C:\GR&A_Trend\"
but the problem is that when execute the "IF" test the system don't recognize the content of the VActTitle variable.
I test this problem whit other Registry Key and in all the case there is this problem.
Macro Scheduler don't see the variable contet and the test fall.
Probably there is a bug in the Macro Scheduler or haw can I solve this problem.
Thank's for the support.
Giovanni Roi

djs
Junior Coder
Posts: 47
Joined: Sun Apr 29, 2012 4:21 pm

Post by djs » Sun Oct 21, 2012 3:51 am

I'm not the expert for registry stuff, but you still have to many variables in your regreadkey line.

From the documentation:

Code: Select all

RegistryReadKey>root_key,key,entry,result_variable
This shows the RegistryReadKey should have a total of 4 parameters.

From your code:

Code: Select all

RegistryReadKey>HKEY_CURRENT_USER,Software\Microsoft\Office\12.0\Access\Security\Trusted Locations\Location0,Path,C:\GR&A_Trend\,VActTitle 
There are 5 parameters being passed. One by One
1 - HKEY_CURRENT_USER
2 - Software\Microsoft\Office\12.0\Access\Security\Trusted Locations\Location0
3 - Path
4 - C:\GR&A_Trend\
5 - VActTitle

My guess is if you correct this, it will work (if you have permissions to read this key).

Dan

User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Sun Oct 21, 2012 2:54 pm

Is this what you want?

Code: Select all

RegistryReadKey>HKEY_CURRENT_USER,Software\Microsoft\Office\12.0\Access\Security\Trusted Locations\Location0,Path,VActTitle
IF>VActTitle=C:\GR&A_Trend\
MDL>VActTitle=C:\GR&A_Trend\
ELSE
MDL>VActTitle Empty
RegistryWriteKey>HKEY_CURRENT_USER,Software\Microsoft\Office\12.0\Access\Security\Trusted Locations\Location0,Path,C:\GR&A_Trend\
ENDIF

Use all registry functions with caution. If you are unfamiliar with the Windows Registry we recommend that you do not use these functions. Removing or modifying a registry entry that you did not create could cause your system to become unstable.

giovanniroi
Junior Coder
Posts: 21
Joined: Fri Jul 03, 2009 4:36 pm
Location: Milan,Italy

Post by giovanniroi » Tue Oct 23, 2012 12:16 pm

Dear Rain
I test the code that You have write and work well, the test is correct and the code work well.
I need to use this code to add registry key used but one my application.

Thank's for the support

Giovanni Roi

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts