Problem when running Access with Admin privilege by ShellExecute

Babycat

Member
Local time
Today, 19:12
Joined
Mar 31, 2020
Messages
278
Hi all

I have a VBS file to run Access app. My Access app writes few values to registry under HKEY_LOCAL_MACHINE, thus it is required to run with Admin privilege.
My PC has only one account: Admin, no passwword and i am using this account. However I still have to use argument "runas" as below code. This make me a bit confused...
Here is my VBS code:
Code:
        ' Run the command with ShellExecute
        objShellA.ShellExecute """" & accessApp & """" , """" & FEPath & """", "", "runas", 1
        ' objShellA.ShellExecute """" & accessApp & """" , """" & FEPath & """", "", "open", 1

1727432425305.jpeg


And, the true problem is: When running with "runas" (admin privilege), I can't type unicode characters for my local language (Vietnamese) in any controls of Access.
It does not happen when i use argument "open", meaning I can type Vietnamese language into controls but now my Access app can not write to HKEY_LOCAL_MACHINE registry.

ChatGPT hints me about the enviroment variable things, the input language may be changed when I use "runas"...
I am still strugglling in this mess and no solution yet.

Is there any one experienced with this problem?
Or any suggestion please.

Thank you
 
Last edited:
can you try and test this script:
Code:
' by Chatgpt
Dim objAccess
Dim FEPath

' Set the path to your Access database
' replace the path with the path of your FE
FEPath= "C:\Users\Administrator\documents\search_formn.accdb"

' Create an instance of MS Access
Set objAccess = CreateObject("Access.Application")

' Open the Access database
objAccess.OpenCurrentDatabase FEPath

' Make MS Access visible (keep it open)
objAccess.Visible = True

' Keep script running to keep Access open
Do While objAccess.CurrentProject Is Nothing = False
    WScript.Sleep 100
Loop
 
can you try and test this script:
Code:
' by Chatgpt
....
' Keep script running to keep Access open
Do While objAccess.CurrentProject Is Nothing = False
    WScript.Sleep 100
Loop

Hi Arnelgp.
First of all: It works
What did you ask ChatGPT?
I am not sure why keeping "script running to keep Access open" could solve the problem...
 
try changing this line to:
Code:
objAccess.OpenCurrentDatabase "" & FEPath & ""
 

Users who are viewing this thread

Back
Top Bottom