compiled script needs admin rights to run properly

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
User avatar
migro
Macro Veteran
Posts: 152
Joined: Thu Nov 06, 2003 5:23 pm
Location: Germany
Contact:

compiled script needs admin rights to run properly

Post by migro » Thu Jul 02, 2009 7:51 pm

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.
regards
migro

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Thu Jul 02, 2009 9:25 pm

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.
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!

User avatar
migro
Macro Veteran
Posts: 152
Joined: Thu Nov 06, 2003 5:23 pm
Location: Germany
Contact:

Post by migro » Fri Jul 03, 2009 10:55 am

Thanks a lot Bob,

easy to integrate, very nice idea :wink:
regards
migro

User avatar
migro
Macro Veteran
Posts: 152
Joined: Thu Nov 06, 2003 5:23 pm
Location: Germany
Contact:

Post by migro » Fri Jul 03, 2009 10:40 pm

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

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Sat Jul 04, 2009 2:56 pm

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......
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

User avatar
migro
Macro Veteran
Posts: 152
Joined: Thu Nov 06, 2003 5:23 pm
Location: Germany
Contact:

Post by migro » Sun Jul 05, 2009 2:44 pm

Dear Bob,
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 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, ;-)
regards
migro

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