Jump to content

Recommended Posts

Posted (edited)

Any idea what's wrong with this? I want to zip a folder of mine.

Run('powershell.exe Compress-Archive -Path "C:\Users\GOD\Desktop\New Folder" -DestinationPath "test.zip"')

Edited by Au3Builder
Posted (edited)

I highly doubt it. Windows PowerShell itself compresses the folder without errors. Only Autoit doesn't and i'm using the previous version.

Edited by Au3Builder
Posted (edited)
9 minutes ago, jdelaney said:

If you run the exact command in the run window, does it execute fully?  windowskey +r

Nope .In short, I have accomplished the task only in two scenarios.

a) I copy & paste the exact command to Windows Powershell console.

b.) I create a powershell script and I run it with powershell.

Edited by Au3Builder
Posted (edited)

Ok, good. I'm sure someone could help with this issue, but it's not an autoit issue. Maybe use the -command parameter?  else you have to keep googleing, or go to a powershell forum

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Posted (edited)

Use 7zip for applications. They have an exe you can use from installers and what not. I pack it with my installers to un  zip my shit. But it can be used to zip stuff. Are use it to create my build archives

Edited by Earthshine

My resources are limited. You must ask the right questions

 

  • Moderators
Posted (edited)

If it is not working from the run command, as was stated, sounds like a PowerShell issue. Perhaps you should ask on a PowerShell forum.

Edited by JLogan3o13

"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!

Posted (edited)
1 hour ago, JLogan3o13 said:

If it is not working from the run command, as was stated, sounds like a PowerShell issue. Perhaps you should ask on a PowerShell forum.

I bet lots of people use AutoIt in conjuction with PowerShell. sooner or later somebody posts me a solution here.nonetheless many thanks to you, Earthshine and Jdelaney.

Edited by Au3Builder
Posted

It worked for me under these conditions:
Changed the double quotes in your code above to single quotes
Changed the single quotes in your code above to double quotes
Use full path for -DestinationPath
Or
Use WorkingDir

Run("powershell.exe Compress-Archive -Path 'C:\Users\GOD\Desktop\New Folder' -DestinationPath 'C:\Users\GOD\Desktop\test.zip'")

Or

Run("powershell.exe Compress-Archive -Path 'C:\Users\GOD\Desktop\New Folder' -DestinationPath 'test.zip'", 'C:\Users\GOD\Desktop')

 

Posted (edited)

and anytime you are dealing with quoted things within a quoted string, you can always set them to a var to ensure that quotes are not the issue.

e.g.

$spath = "'C:\Users\GOD\Desktop\New Folder'"

$dpath = "'C:\Users\GOD\Desktop\test.zip'"

Run("powershell Compress-Archive -Path " & $spath & " -DestinationPath " & $dpath)

 

Edited by iamtheky

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

Posted (edited)
7 hours ago, Subz said:

 

Run("powershell.exe Compress-Archive -Path 'C:\Users\GOD\Desktop\New Folder' -DestinationPath 'C:\Users\GOD\Desktop\test.zip'")

 

Thank you! I can't explain why but putting double & single quotes in the right order as mentioned above solved the issue .

it would be great If somebody could elaborate on this so I knew what the point is.

Edited by Au3Builder
Posted

If you run the code in Cmd, you'll see the error, it strips the quotes unless you use single quotes or escape the double quotes, its a fairly common issue when running PowerShell.exe from command line.

Compress-Archive : A positional parameter cannot be found that accepts argument 'Folder'.
At line:1 char:1
+ Compress-Archive -Path C:\Users\GOD\Desktop\New Folder -DestinationPath test.zip
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Compress-Archive], ParameterBindingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,Compress-Archive

 

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
  • Recently Browsing   0 members

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