Run an AutoIt script as a local administrator?

Questions about WAPT Packaging / Requests and help regarding Wapt packages.
Forum Rules
Community Forum Rules
* English support on www.reddit.com/r/wapt
* French community support is available on this forum
* Please prefix the topic title with [RESOLVED] if it is resolved.
* Please do not edit a topic that is tagged [RESOLVED]. Open a new topic referencing the old one.
* Specify the installed WAPT version, full version, and build number (2.2.1.11957 / 2.2.2.12337 / etc.) as well as the Enterprise/Discovery edition.
* Versions 1.8.2 and earlier are no longer supported. The only questions accepted regarding version 1.8.2 are related to upgrading to a supported version (2.1, 2.2, etc.).
* Specify the server OS (Linux/Windows) and version (Debian Buster/Bullseye - CentOS 7 - Windows Server 2012/2016/2019).
* Specify the OS of the administration/package creation machine and the machine with the problematic agent, if applicable (Windows 7/10/11/Debian 11/etc.).
* Avoid asking multiple questions when opening a topic, otherwise it may be ignored. If there are multiple topics, open separate topics, preferably one after the other and not all at the same time (i.e., do not spam the forum).
* Include code snippets, screenshots, and other images directly in the post. Links to Pastebin, Bitly, and other third-party sites will be systematically removed.
* As with any community forum, support is provided voluntarily by members. If you require commercial support, you can contact Tranquil IT's sales department at 02.40.97.57.55
Locked
User avatar
Jonattend
Messages: 43
Registration: March 26, 2018 - 2:45 PM

June 13, 2018 - 4:55 PM

Hello,

I'm making good progress with WAPT and creating and modifying existing packages.

For educational purposes, I need to install an application that requires, on its first startup (and only then), the user to enter a name, organization, and serial number.

I've tried various things without success so far:
- regShot before and after inserting the serial number, then exporting to a .reg file
- silently executing the .reg file after installation (via the `def install()` function in the WAPT package): the software doesn't activate... there might be other file modifications/creations after the license is inserted.

Another test: via AutoIt
- installing the application via WAPT
- in WAPT's `def install()` function, running an AutoIt script to start the application and simulate keyboard input...
The program installs successfully, but the problem is that the AutoIt script is executed under the System account... and the program, if started under the System account, doesn't seem to recognize the script.

In my AutoIt script, I forced the program to launch as a local administrator.
It appears correctly in the processes, but my AutoIt script (launched as the system account) doesn't run...
Basically, I end up with one program running as a local administrator and a script running in a queue as the system account.
Launching both as the system account doesn't help...

I haven't found any option in the Python script to request that the script be launched as an administrator...

Perhaps there's a simpler method...?

PS: By installing the software normally and then manually running my AutoIt script (as an administrator), activation is successful...

Thanks for any suggestions. ;)
WAPT Server version: 1.8.1 on Debian 10
WAPT Agent version: 1.8.1.6756
WAPT Setup version: 1.8.1.6756 on Windows10 v1909
WAPT Deploy version: 1.8.1.6756
User avatar
Jonattend
Messages: 43
Registration: March 26, 2018 - 2:45 PM

June 14, 2018 - 1:45 PM

Hello,
I was able to contact the software publisher who just provided me with a license file adapted to my license and my institution.
So, copying and pasting the license file into the correct location should be OK (via `def install()`).

I'm testing it and will give you feedback. ;)
WAPT Server version: 1.8.1 on Debian 10
WAPT Agent version: 1.8.1.6756
WAPT Setup version: 1.8.1.6756 on Windows10 v1909
WAPT Deploy version: 1.8.1.6756
User avatar
Jonattend
Messages: 43
Registration: March 26, 2018 - 2:45 PM

June 14, 2018 - 3:56 PM

Still nothing... the publisher did provide me with a license file... but it needs to be launched once to activate... worse, it opens a dialog box... which I have to cancel before I can finally see that the software is activated... I'm continuing my search, but I'm starting to run out of ideas :roll:
WAPT Server version: 1.8.1 on Debian 10
WAPT Agent version: 1.8.1.6756
WAPT Setup version: 1.8.1.6756 on Windows10 v1909
WAPT Deploy version: 1.8.1.6756
User avatar
sfonteneau
WAPT Expert
Messages: 2318
Registered: July 10, 2014 - 11:52 PM
Contact :

June 14, 2018 - 6:13 PM

Two possible solutions? 1.

Create an "interactive" scheduled task that launches the installation; in my opinion, keyboard emulation works within it.
Another possible solution:

Create an "interactive" Windows service that launches the installation, then run it.

Both solutions are very ugly...

I also can't get `runas` to work as the system account or use `psexec` as the system account.

Another solution:

I've seen a friend do it.

Integrate the administrator username and password into AutoIt (I know it's possible).
Launch the AutoIt installation in a `session_setup`; AutoIt will then launch automatically as administrator.

However... it's easy to retrieve the password from AutoIt...

Simon
User avatar
Jonattend
Messages: 43
Registration: March 26, 2018 - 2:45 PM

June 15, 2018 - 08:49

Thanks for the suggestions...

I have an idea, but I don't know if it's feasible with WAPT:
- silent installation of the program via WAPT (SYS account)
- in the WAPT package, `def install()`: creation of an interactive scheduled task at Administrator account login
- in this task, opening the AutoIt file launching the program + keyboard simulation
- still in AutoIt: deletion of the administrator scheduled task + deletion of the AutoIt file itself... + reboot.

Perhaps a session setup would be simpler? (I haven't tested session setup yet...)

What do you think?
WAPT Server version: 1.8.1 on Debian 10
WAPT Agent version: 1.8.1.6756
WAPT Setup version: 1.8.1.6756 on Windows10 v1909
WAPT Deploy version: 1.8.1.6756
User avatar
Jonattend
Messages: 43
Registration: March 26, 2018 - 2:45 PM

June 15, 2018 - 09:41

I just tried session_setup: it works fine for my local Administrator... but the problem is that it also runs for my domain users.

Ideally, the session setup should only need to be launched once by the Administrator and that's it.

The document clearly states that "The session_setup for each package is executed only once per package or package version and per user profile"...I need to find a way to disable session_setup after it has been launched by the Administrator...".

Currently in my session_setup():

Code: Select all

run(r'....\fichier_autoIT_activation_logiciel)
Final objective: session_setup():

Code: Select all

run(r'....\fichier_autoIT_activation_logiciel)
"desactiver le session_setup"
"suppression du fichier fichier_autoIT_activation_logiciel"
WAPT Server version: 1.8.1 on Debian 10
WAPT Agent version: 1.8.1.6756
WAPT Setup version: 1.8.1.6756 on Windows10 v1909
WAPT Deploy version: 1.8.1.6756
User avatar
sfonteneau
WAPT Expert
Messages: 2318
Registered: July 10, 2014 - 11:52 PM
Contact :

June 15, 2018 - 11:13

The simplest way is to add a condition in the session setup.

Code: Select all

if get_current_user() == u'Administrateur':
         run(r'....\fichier_autoIT_activation_logiciel)
User avatar
Jonattend
Messages: 43
Registration: March 26, 2018 - 2:45 PM

June 15, 2018 - 4:51 PM

Phew! I finally did it!

Thanks for the tip about session_setup and get_current_user() ;)

In my def install(), I install the software.

In session_setup():

Code: Select all

if get_current_user() == u'Administrateur':
         run(r'....\fichier_autoIT_activation_logiciel)
         delete_ay_next_reboot("C:\xxxxx\fichier_autoIT_activation_logiciel")
I've learned quite a lot from all of this :)
I have a second software program of the same type, I'm going to try that again and see the result.

Resolved!
WAPT Server version: 1.8.1 on Debian 10
WAPT Agent version: 1.8.1.6756
WAPT Setup version: 1.8.1.6756 on Windows10 v1909
WAPT Deploy version: 1.8.1.6756
Locked