Is there a possibility to detect, if a user haven't sufficient rights (logged in as normal user) so i can prompt him with a message?
I'm doing some registry read/write actions to HKLM. Without sufficient rights the macro won't work.
compiled script needs admin rights to run properly
Moderators: JRL, Dorian (MJT support)
compiled script needs admin rights to run properly
regards
migro
migro
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
The best way is probably to try to do it.....
At the beginning of the script, try to write/edit/delete some dummy test info to the registry. Check for error message, or validate that it wrote properly.
If it failed then you know you don't have permissions and can stop the macro.
If it passes, delete the entries, and continue the macro as normal.
At the beginning of the script, try to write/edit/delete some dummy test info to the registry. Check for error message, or validate that it wrote properly.
If it failed then you know you don't have permissions and can stop the macro.
If it passes, delete the entries, and continue the macro as normal.
Last edited by Bob Hansen on Fri Jul 03, 2009 6:19 pm, edited 1 time in total.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
Here the chunk of code as i implemented it. Maybe it is helpfull for somebody who have the same needs:
Code: Select all
Label>Start
Registrywritekey>HKEY_LOCAL_MACHINE,SOFTWARE\MyApp,DBTCeck,Admin
RegistryReadKey>HKEY_LOCAL_MACHINE,SOFTWARE\MyApp,DBTCeck,readDBTCheck
IF>%readDBTCheck%=Admin
RegistryDelVal>HKEY_LOCAL_MACHINE,SOFTWARE\MyApp,DBTCeck
ELSE
Gosub>NoAdmin
Goto>Exit
ENDIF
SRT>NoAdmin
LibFunc>user32,MessageBoxA,r,0,No adminrights. Please execute the app as administrator.,MyApp,8208
End>NoAdmin
Label>Exit
regards
migro
migro
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
Looks good migro, well done. Thanks for sharing that. Having an idea is one thing, but making it happen with code is so much better. Well done!
I am curious why you made a SubRoutine vs. just putting that one line in the ELSE block? It doesn't really matter, there are a hundred ways of doing something, and the one that works for you is fine. I just like to learn how/why others work......
I am curious why you made a SubRoutine vs. just putting that one line in the ELSE block? It doesn't really matter, there are a hundred ways of doing something, and the one that works for you is fine. I just like to learn how/why others work......
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
Dear Bob,

I got a whole bunch of messages in my script and i like to have them all together in a messagepart. So its easyer for me to translate them all to my english spoken colleagues, when the functional coding is done,I am curious why you made a SubRoutine vs. just putting that one line in the ELSE block? It doesn't really matter, there are a hundred ways of doing something, and the one that works for you is fine. I just like to learn how/why others work......

regards
migro
migro