Sign in to follow this  
Followers 0
woody619

Problem with Send in Powershell (Ran as Admin)

5 posts in this topic

Hi,

I'm having trouble with the last window ("Administrator: Windows PowerShell")receiving the characters via "Send" I'm  thinking it must be something with the Powershell being run as admin window.  What am I doing wrong?  Please let me know if there's an easier way than how I'm doing it.  Thanks

Run ("cmd.exe")
               WinWaitActive ( "C:\Windows\system32\cmd.exe")
                  Send ( "powershell" & "{ENTER}" )
                  Send ( "Start-Process PowerShell –Verb RunAs" & "{ENTER}" )
               WinWaitActive ( "Administrator: Windows PowerShell")
                  Send ( "powershell.exe -noexit C:\ps1\script1.ps1" )

Share this post


Link to post
Share on other sites



Confusing me to death?  lol, kidding.

Send is not something you should rely on to be 100% accurate.  To many variant factors can screw it up.

My question is this...  What's wrong with ShellExecute() or RunAs()? to run powershell directly without the need of all the sends etc...


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Or skip the multi-language scripting of PS altogether and just perform the tasks in AutoIt?


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Thanks for the help guys.  Sorry new to scripting, so didn't think about using ShellExecute which works great.

Can't use RunAs it's part of a tool to be use by a group, so want to avoid putting credentials in script.

I'm using powershell, because it allows me to remotely reboot the machine.  It prompts for the name of the machine in Autoit's GUI and I'm hoping it will pass it somehow over to powershell (hoping send command) when it's executed and then does it.

Is there a way I can get the variable information passed to powershell when powershell executes and prompts for input?  The gui i created in Autoit has a field for the computername.

It doesn't seem that the Administrator Powershell Window can take the characters when sent via Send

Edited by woody619

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

This prompts for user input, then uses that input in a Powershell command.  It then goes on to do other things with the output of that command, but if you are just rebooting then you would be done there.

There is not a need to ever send things to the powershell window (that i have encountered), you can just run the commands from autoit.

Edited by boththose

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0