B4J Question Run as administrator shell

Douglas Farias

Expert
Licensed User
Longtime User
Hi all.
how can i check if a file is runing as administrator?

on my .jar i m opening a another .exe file, not made in b4j, i need open this .exe with administrator rights
the same of click with right mouse button and select run as administrator.

how can i run or check administrator on b4j (shell)?

thx
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Are you starting the other exe file with jShell? It will run with administrator privileges if the B4J process runs as administrator.

You can use this code (on Windows) to test whether the process has administrator privileges:
B4X:
Sub RunningAsAdministrator As Boolean
   Try
     File.WriteString("\", "test.txt", "test")
     File.Delete("\", "test.txt")
     Return True
   Catch
     Return False
   End Try
End Sub
 
Upvote 0
Top