Jump to content
Eggsplorer

Powershell Command in Autoit

Recommended Posts

Eggsplorer

Hi,

I would like to install chocolatey packages (OneGet) via Autoit.

Manually without Autoit I would just open Powershell and use this command:

Install-Package -Name Firefox -Force

It also works with cmd (see attachment 1)

powershell.exe -Command Install-Package -Name Firefox -Force

With Autoit I tried the following code:

RunWait(@ComSpec & ' /k ' & 'powershell.exe -Command Install-Package -Name Firefox -Force', @SW_SHOW)

It doesnt work at all. I don't even see a cmd window.

When I add @SystemDir the Windows appears with the error in attechment 2.

Is there another way to run PowerShell Commands with Autoit?

I would like to avoid starting Powershell, waiting for the window, sending the command and sending Enter.

Thanks

Eggsplorer
 

cmd.jpg

autoit.jpg

Edited by Eggsplorer

Share this post


Link to post
Share on other sites
AutoBert

You forgot the 2. parameter if you didn't know what to use just use '' or @scriptdir.

 

Btw.: soon is easter, a good time to eggsplore gardens, parks etc.

Edited by AutoBert

Share this post


Link to post
Share on other sites
Eggsplorer

Ah right. That's why it worked with @SystemDir.

Now I am using @UserProfileDir since I am logged in as "Administrator".

I am still receiving the same error (red font in original post).

How can this be?
AutoIt uses the same command as I pasted to cmd!

Is there an other way to execute PowerShell commands with AutoIt?

Btw.: I am eggsploring AutoIt for now ;)

Share this post


Link to post
Share on other sites
rudi

Hi.

1st of all: I have no experience at all with Powershell 5.0, Packet Handling is nothing I've ever used so far.

 

The message is telling ... keine Übereinstimmung für die angegebenen Suchkriterien und den Paketnamen "Firefox"

So it looks, that within the context something is not available, when started within a @comspec

Maybe one of the other commands from here might help to work out, what exactly is missing?

Get-Package -Source <string> [-ListAvailable] [-Updates] [-ProjectName] [-Filter <string>] [-First <int>] [-Skip <int>] [-AllVersions] [-IncludePrerelease] [-PageSize]

 

Regards, Rudi.


Earth is flat, pigs can fly, and Nuclear Power is SAFE!

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

  • Similar Content

    • JuanFelipe
      By JuanFelipe
      Cambiar a español Hello friends, I need help with a problem I have, I want to know if there is any way to update a GUI already running, that is I have a GUI of a certain size and with a button I would like to enlarge it:
      example: $ form1 = GUICreate ("", 200,100,0,0)   When you press the button, the gui increases its size, and actuates the new size.
    • BogdanNicolescu
      By BogdanNicolescu
      While 1 / / / A whole bunch of codes found in help and here: https://www.autoitscript.com/autoit3/docs/ / / / WEnd OR:

       
      HotKeySet("{ESC}", "Terminate") While 1 MouseClick("Right",674,422) MouseClick("Left",673,447) Sleep(2000) / / / A whole bunch of codes found in help and here: https://www.autoitscript.com/autoit3/docs/ / / / MouseClick("Left",675,339) SLeep(3000) WEnd Func Terminate()     Exit 0 EndFunc  
      Sorry if i should't let this here to be found by newbies like me -.-'
    • santoshM
      By santoshM
      Dear friends i am facing a problem , i have created a window in autoit some time it is moving with the mouse curser even if iam not clicking the window 
    • sumanth1980
      By sumanth1980
      Here i am wrote a simple lines to install basic applications but when i clicked on one application/program to install it was working fine but when i cancel the program in the middle to install another program it was not working. I am not an expert in this but i want a solution for this ... Can any one help me on this....
      ORG-1.au3
    • PleaseHelpMEIWillLoveyou
      By PleaseHelpMEIWillLoveyou
      Is there a way to use a custom terminal or something from my pc and run a script on another pc.
      please let me know if its possible
      (not for anything bad just for a project im working on)
×