cancel
Showing results forĀ 
ShowĀ Ā onlyĀ  | Search instead forĀ 
Did you mean:Ā 
nopeno
Level 4

After setup complete success, running a .bat file in a cmd prompt with elevated priviledges

Using Installshield 2019, i have a .bat file that runs schtsk to create some scheduled tasks after the setup is run. Unfortunately, I recently discovered that the cmd prompt the .bat is run in is not running with elevated privileges, even though its run with LaunchAppAndWait.   Schtsk will deny access when run from cmd prompts that aren't adiministrators, and running the setup program as admin doesn't change the privileges of the other things the installer executes.  How can i make sure the cmd prompt we run the .bat file from is runas?

 

Thank you.

 

Labels (1)
0 Kudos
(5) Replies
Revenera_Ian
Revenera Moderator Revenera Moderator
Revenera Moderator

Hi @nopeno,

Thank you for your post.

This is a known limitation with the LaunchAppAndWait InstallScript function. To launch a process as an Administrator with elevated privileges, you need to call the LaunchApplication InstallScript function instead.

The following link is a link to the documentation with more information about LaunchApplication:

https://docs.revenera.com/installshield25helplib/installshield25helplib.htm#Subsystems/LangRef/helplibrary/LaunchApplication.htm

Here an excerpt from the documentation that I would focus on:

If you are not using LAAW_OPTION_USE_SHELLEXECUTE, update the LAAW_STARTUPINFO system variable before calling LaunchApplication to customize the behavior of the application.
If you are using LAAW_OPTION_USE_SHELLEXECUTE, customize the LAAW_SHELLEXECUTEINFO structure to customize the behavior of the application.

If you are using LAAW_OPTION_USE_SHELLEXECUTE on systems running Windows Vista or later and you want to launch the application using the full administrator account (similar to right-clicking the executable file to be run and clicking Run as Administrator), set LAAW_SHELLEXECUTEVERB to runas before using LaunchApplication in your script:

LAAW_SHELLEXECUTEVERB = "runas";

This ensures that the application is always run with full administrator privileges regardless of whether the application to be launched has an application manifest with relevant settings. Note that this may trigger a User Account Control (UAC) prompt for consent or credentials.

On systems running operating systems earlier than Windows Vista, if runas is used, a Run As dialog box is displayed. The behavior is similar to right-clicking the executable file to be run and clicking Run As. This dialog box enables the end user to select the user account that should be used to run the application.

Please give this suggestion a try. Does it work for you?

Please let us know if you have any questions or concerns. Thanks!

0 Kudos

Hello again Ian, thanks for your help.  If the bat file in question was named Create.Scheduled.Task.bat, then the after setup completed successful task "file name and command line"

would look like LaunchApplication(Create.Scheduled.Task.bat)

That much I understand.  I'm afraid i don't know how to account for the additional options, having read through the link you provided, like where LAAW_OPTION_USE_SHELLEXECUTE would be set, for example.

0 Kudos
Revenera_Ian
Revenera Moderator Revenera Moderator
Revenera Moderator

Hello again @nopeno, you're welcome. We're happy to help.

You need to pass LAAW_OPTION_USE_SHELLEXECUTE as an argument for the nOptions parameter indicated in the documentation that I referenced. Please give this a try. Does this work for you?

Please let us know if you have any questions or concerns. Thanks!

0 Kudos

I did pass LAAW_OPTION_USE_SHELLEXECUTE as an option

and added LAAW_SHELLEXECUTEVERB = "runas" in my bat file, which i think is what the task describes, but nothing changed, the bat file still executes as un-elevated.

 

the filename and command line for the after-setup complete success run of the bat file now says: LaunchApplication(Create.Scheduled.Task.bat, LAAW_OPTION_USE_SHELLEXECUTE)

 

0 Kudos

Ian, would it help sent you the .bat file in question? 

0 Kudos