Kinook Software Forum

Kinook Software Forum (https://www.kinook.com/Forum/index.php)
-   [VBP] General Discussion (https://www.kinook.com/Forum/forumdisplay.php?f=2)
-   -   Need to restart build elevated with all arguments (https://www.kinook.com/Forum/showthread.php?t=5646)

thebick 03-03-2020 02:25 PM

Need to restart build elevated with all arguments
 
I am trying to automate a Visual Build Pro process (that I inherited) that must run elevated, and has some VBScript to restart it as elevated if it determines that it's not.

If I double-click on the .bld file, I get two VBP windows: the first is unelevated that promptly completes; the second is elevated, so clicking the green arrow sends everything off fine. I don't get a dialog asking me if I want to allow this program to run or make modifications to the system.
If I right-click > "Run As Administrator", I get just the one elevated window, and all is well.
OS: Windows 10

I have a command-line script with needed arguments that works if I run it in a "Run as Administrator" Command or PowerShell window.
But when I run the script from the command line (PowerShell or Command) or from Jenkins via PowerShell or batch, I get two problems:

1. "Error building application: Build already in progress"
I think this is because of the attempted restart as elevated, but the original command should have completed, so no build should have been in progress. I have looked all over this site and the web trying to find out what causes this, and have found nothing.

2. The VBScript uses the following to restart as elevated ("IsElevated" is a macro that the script uses):
Set objShell = CreateObject("Shell.Application")
objShell.ShellExecute "C:\Program Files\VisBuildPro9\VisBuildPro", "IsElevated=True """ + mybuildfile.bld + """", "runas", 1

The result seems to be that an elevated GUI is launched, and without the other arguments that I had in the command line, including macro definitions. I would like the command line to be re-launched elevated. Or is there a way that I can force the command line to run elevated (remember, I want to do this in Jenkins)?

My account has some administrator privileges. E.g., in Task Manager, I can modify the Logon properties of services. And whether running VBP or Task Manager from the GUI, I don't get the dialog asking me for permission to run the process.
But for some reason, it's not "elevated". Is there a simple command-line check to see whether my account is elevated?

I also note in the same VBScript part of the .bld after the above (the Property keys should not have an embedded space, but Preview puts a space in there :confused:):
'clear out the current project and set it up to log an informational message
Application.Project.New(False)
Application.Project.Steps(0).Add "Log Message", 0
Application.Project.Steps(0).Item(0).Name = mybuild.bld + " was restarted elevated"
Application.Project.Steps(0).Item(0).Property("pausebefore") = "3"
Application.Project.Steps(0).Item(0).Property("Message") = _
"Build was started unelevated. Re-opened elevated" + vbCrlf + _
"This window can be closed at any time"

Application.Builder.Start -1, -1, 0, ' Starting the build with a step designed to log a message is the only way I could find to output a message about why the build opened a second window.

I have tried to find anything about "pausebefore", but no luck. I find that if I increase the value, it only delays the message appearing in the unelevated GUI.

Note: for security reasons, that system is not connected to the Internet, and installing a program goes through a lot of hurdles.

kinook 03-03-2020 10:40 PM

See https://www.kinook.com/Forum/showthread.php?t=2258

The pausebefore property corresponds with the Pause x seconds before... option on the General tab of the Step Properties dialog.

https://kinook.com/VisBuildPro/Manual/buildrules.htm


All times are GMT -5. The time now is 05:54 PM.


Copyright © 1999-2023 Kinook Software, Inc.