Jump to content

Problem with Send in Powershell (Ran as Admin)


 Share

Recommended Posts

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" )
Link to comment
Share on other sites

  • Moderators

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...

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.

Link to comment
Share on other sites

  • Moderators

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

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...