Discussions related to Visual Prolog
daveplummermd
VIP Member
Posts: 81
Joined: 18 Jul 2006 17:18

Console program as Adminstrator

Unread post by daveplummermd »

Hello. Trying to run Robocopy as a command line or within a batch file and wish to use robocopy's backup switch (/ B) wich requires administrative privileges.
Using this code:

Code: Select all

  ...   Command =             string::format(@[robocopy %  % /e /b /mir /xo /im /np /LOG:Backup.log], SourceDir, DestinationDir),         RunObj = useExe::new(Command),         RunObj:run(),         ...
The robocopy log reveals an error for lack of admin privileges.
I am using Windows 11 and signed in under an administrator account.
Are there any suggestions to "run" the useExe object as admin?
Thanks in advance.
Dave
Dave Plummer
User avatar
Thomas Linder Puls
VIP Member
Posts: 1401
Joined: 28 Feb 2000 0:01

Re: Console program as Adminstrator

Unread post by Thomas Linder Puls »

That is only possible if your program itself run in elevated state (you can require that using an option in the project settings, which will change the manifest file).

If your program runs in normal mode and you want to launch an elevated program from it, then you will need to use shell_api::shellExecute with "runas" as Command. But that will just launch the program; you will not get any handle to it or any other information about the process at all.
Regards Thomas Linder Puls
PDC
daveplummermd
VIP Member
Posts: 81
Joined: 18 Jul 2006 17:18

Re: Console program as Adminstrator

Unread post by daveplummermd »

This is very helpful. Thanks Thomas!
Dave Plummer
Post Reply