September 26, 2022, 05:53:52 AM


Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........

Run your program as Administrator

Started by Andy, June 01, 2016, 06:29:44 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.


June 01, 2016, 06:29:44 AM Last Edit: June 01, 2016, 06:46:07 AM by Andy
Here is my example of how to make your exe file run as an Administrator.

How to:

1. Setup - you can run setup_stringmap.exe - just browse to your IWBDev / EBasic root folder in C:\Program Files and click OK.

Alternatively, if that doesn't work, copy the .lib file to your Libs folder, the .inc file to your include folder.

2. Compile regviewer.iwb and run it.

If asked if you want to allow this program to run, obviously click 'yes'.

3. Navigate to HKEY_USERS
4. You will see registry keys like S-1-5-18, or 19 etc.
5. Click on one of these to open

If it opens, the regviewer.exe has been elevated to admin level and you will see the sub keys listed.

If it doesn't work, the program will freeze.

Bottom line - you can add / amend the following code in your own program

$include ""
$include ""
$IncluDE ""

'                                                   '
' This code to run this program as an Administrator '
'                                                   '

string MyProgram = "regviewer.exe" 'Name of this exe to run as admin.

string RAS2 = ""
RAS2 = ltrim$(SMRegGetValue("HKEY_CURRENT_USER\\Software\\StringMap","RunAsAdminDone"))

if RAS2 = "1"
  SMRegSetValue("HKEY_CURRENT_USER\\Software\\StringMap",getstartpath + MyProgram,"RunAsAdmin")
  system getstartpath + "RunAsAdmin.exe"

'                           '
' End of Administrator code '
'                           '

By changing the string "MyProgram" to your own .exe name of your code.

Note - you need the runasadmin.exe and your own exe in the same folder, but you could change that if you wish.

There are other ways to do this, but I think you might like this.

BTW - Regviewer now reads / writes qwords up to and including FFFFFFFFFFFFFFFF (16 F's).

Not bad at 50 today!

Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.