Test registry Key availability
Moderators: Dorian (MJT support), JRL
-
- Junior Coder
- Posts: 21
- Joined: Fri Jul 03, 2009 4:36 pm
- Location: Milan,Italy
Test registry Key availability
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
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
-
- Macro Veteran
- Posts: 267
- Joined: Mon Sep 27, 2010 8:57 pm
- Location: Seattle, WA
-
- Junior Coder
- Posts: 21
- Joined: Fri Jul 03, 2009 4:36 pm
- Location: Milan,Italy
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
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
-
- Macro Veteran
- Posts: 267
- Joined: Mon Sep 27, 2010 8:57 pm
- Location: Seattle, WA
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
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
-
- Junior Coder
- Posts: 21
- Joined: Fri Jul 03, 2009 4:36 pm
- Location: Milan,Italy
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
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
I'm not the expert for registry stuff, but you still have to many variables in your regreadkey line.
From the documentation:
This shows the RegistryReadKey should have a total of 4 parameters.
From your code:
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
From the documentation:
Code: Select all
RegistryReadKey>root_key,key,entry,result_variable
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
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
Is this what you want?
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.
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
-
- Junior Coder
- Posts: 21
- Joined: Fri Jul 03, 2009 4:36 pm
- Location: Milan,Italy