Jump to content

Recommended Posts

Posted (edited)

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
Posted (edited)

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
Posted

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 ;)

  • 2 weeks later...
Posted

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!

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
×
×
  • Create New...