Hi Team,
I want to open command prompt as runas administrator to install my setup.exe file in windows.
below is my playbook.
[Setup_install.yml]
Hi Team,
I want to open command prompt as runas administrator to install my setup.exe file in windows.
below is my playbook.
[Setup_install.yml]
My first guess is case of administrator. In your task, you have the first letter capitalized. In your inventory file, it is lowercase.
Become isn’t necessarily used to ‘run as administrator’ in Windows but rather to change the logon from a network to interactive logon with credentials to use for delegation. Normally a WinRM process is run with the full Administrative rights of an account and you can verify that by running
`
`
This will return a whole bunch of information but if the label key contains a ‘High Mandatory Label’ you know you are running as an admin. In older versions of Ansible, a become task may not have admin rights and since 2.5 it is done as a best effort attempt. I would do the below to verify you are least get the High Mandatory Label returned when using become to verify that process is run with admin rights as well.
`
`
As for why the process is still running it could be a few different things;
Become runs the task in a pseudo interactive logon so it may be prompting the user for something causing it to hang
The args you are using aren’t the correct silent args for the process
Some else?
What I would try
Run the same command locally and see if it works or not
Check the log file when being installed with Ansible to see if there’s anything in there that might indicate what it’s waiting for
Try running the task with async and become, this changes a few things with how the console is spawned and killed so may work for you
Use procexp to see what processes are still running, whether the main powershell exe that executes the module is still running, if setup.exe is still running and so on.
Thanks
Jordan
Thanks Jordan for your prompt response.
Issue was with argument which i was passing in win_command.
win_command: 'C:\temp\setup.exe /SP /VERYSILENT /DIR=C:/temp /LOG=C:/temp/Install.log’
Here temp directory was not there to create log file but after creating temp directory, i’m able to install setup.exe file successfully.
Also as you mentioned, become method is not require to run ‘RunAs Administrator’. I’m able to install setup.exe without become method.
Regards,
Venkat