I have a program that I need to have execute a shell command in administrator mode. Is this possible from a Xojo app? If so, how do I structure the shell.execute command?
- Dale
I have a program that I need to have execute a shell command in administrator mode. Is this possible from a Xojo app? If so, how do I structure the shell.execute command?
If you’re using the Shell class, you could probably use the runas command which comes with Windows.
You could also use a declare to invoke the runas verb directly:
Sub LaunchAsAdministrator(ProgramEXE as FolderItem, ParamArray Arguments as String)
#If TargetWin32
Declare Function ShellExecuteW Lib "Shell32" (HWND As Integer, verb As WString, file As WString, params As WString, directory As WString, cmd As Integer) As Integer
Dim params as String
params = Join(Arguments, " ")
Call ShellExecuteW(0, "runas", ProgramEXE.AbsolutePath, params, App.ExecutableFile.Parent.AbsolutePath, 1)
#Endif
End Sub
Thanks, Andrew. I’ll look into that as a solution.