Has anyone created a ZIP file via scripting - or even via a batch file on Windows 10 ?
I create zipfiles using a one-line batchfile with 7-Zip:
"C:\Program Files\7-Zip\7z.exe" a "MyFiles.zip" @Content.txt
That calls 7zip.exe (you need whole path), creates the file MyFiles.zip and uses a text file with a list of files and folders.
OK, I found a method now that should work on any Windows machine, using a batch file that calls a vbs script, which in turn uses a call to a standard zipping library that only has the dot net interface.
I finally found time to start finishing this job. I got the batch file in place but there is a problem with access rights. When I run the batch from the command prompt or from Windows Explorer, it works fine. When I call it via the File.execute( ) function it throws an error.
The batch file uses a VBS to create the ZIP. I guess the VBS is so dangerous that you cannot run it from a batch file. So I will have to look at downloading an exe for zipping after all.
for a while I was working with this : https://nsis.sourceforge.io/Download
Now I'm working the way I described above, copying the files to my user folder before.
But this nullsoft solution is a very good thing!
Have a look at it. There are some examples you can copy and change.
Klaus, how are you getting around Windows exaggerated security issues? I can execute the batch when double-clicking it, I can execute the zip command when running it in the command line, but I cannot execute the batch file from ExtendScript.
I was testing a long time until I gave up.
The only way is, to use your own personal folder.
All my scripts at customers side are copied to C:\Users\<USERNAME>\AppData\Roaming\Adobe\FrameMaker\number
There I create a folder "4xscripts" to copy my scripts there.
There the rights are granted.
This way I can claim, that no rights will be violated.
Otherwise, I think, admins have to change the folder rights. And that is to heavy and complex. (The point where I gave up ;-)) )
Yes, I have been putting all my scripts in the AppData area for a long time. But I need to create a ZIP to be uploaded somewhere and there is no way I can move all the company documents into an AppData of a single user.
I guess I will have to find a way around this idiocy that is called MicroSucks.
(frustrated after spending hours of trials and getting nowhere)
My thoughts are with you.
I've not strugggeld for hours, but for days. Just try that nullsoft software. It takes some time to know it. It creates self extracting exe-files.
But that could be the next problem, when customer users are not allowed to install software that isn't approved by IT people
My next thought: Have you tried running the batch file as administrator?
I'm to tired to create an example by myself. I'll try it tomorrow.
This is not a solution, as normal users have to use my app to create a Zip (not a self-extracting one) to upload to a server. No need to test this as it will not solve anything. Thanks for offering.
How you tried a batch file that runs in Windows PowerShell? I seem to remember that PowerShell has a compress archive command.
How do I run a WIndows PowerShell ? The only option I have is use File.execute( ). I can create a batch file and execute it that way. I cannot hand any arguments to the execute( ) function - or I would not have needed a batch file at all.
Generate a text file. Add the commands as required then save it with a .ps1 extension. Then execute this new batch file.
I've not tried it yet, but it could work...
The other problem is that Windows finds it necessary to bring this stupid "are you sure you want to run such a horribly unsafe program on your computer' EVERY SINGLE TIME. I do hate Windows so much. Why on earth did everyone fall for that crappy system? Oh wait, I know, it was CHEAPER !!!!!
Penny wise and pound foolish. Short-sighted stupid business managers are ruling the planet.
Maybe this link helps…
Anything is about security. If you write an FDK Plugin, you won't have to care about that.
Why not writing a Plugin? O wait, I know it, ES is CHEAPER!!! (#scnr)
Hope this helps?
Thanks, I have been trying to get a PowerShell to run without throwing all the dialogs. So far no dice.
About creating an FDK plugin: that is complete overkill for most of the projects as it requires getting friendly with Microsoft's constantly changing Visual Studio and the intricacies of C++. Also, I would have to maintain a different VS version for each FM version as MS tends to change their entire framework every couple of years and have never understood what it means to be backward - or anyward - compatible.
What would help is is someone (Adobe dev team or maybe you) would create a simple straightforward little FDK Client that can ZIP a bunch of files (and maybe also throw in the unzip function while you're at it) and makes it available through the CallClient method in ESTK. Combining the best of both worlds.
glad you manged to get this stuff working.
My point of view is, that ES is for easy to not that complex use cases. If zipping is an issue, it's a complex issue, where ESTK is not designed for. So developing plugins is my choice for such use cases.
But let's get more constructive, and Maybe adobe is listening. So we need in ESTK:
- As zipping is getting a common use case more and more, this should be captured by ESTK and FDK, to get easy access to this functionality for anyone.
- possibilites to execute application with Parameters (File.execute doesn't support parameters)
- access to system resources like the Registry
- possibilities for XSLT Transformation outside of the FM Environment (native XML to anything)
I think it's a job for Adobe (if they want to) not for the community to provide such functionality. It has to be integrated for anyone, and not in a plugin developers have to know that this is existing.
No, I did not get it working, even after trying all the variants I found on StackOverflow. PowerShell sounds good but is a horror when trying to call it from a batch file.
Could you send the powerscript and it's call in ES by PM?
I have it working as follows:
Extend script must write two files the first is the bat file which contains the following:
PowerShell -ExecutionPolicy Bypass -File "C:\path_as_required\zipTest.ps1"
The second file is the PowerShell script which for example can be written to compress a folder or many individual files:
Compress-Archive -Path "D:\Support\CGM" -DestinationPath "D:\Support\CGMzip.zip"
This works without any annoying warnings because of the ExecutionPolicy Bypass.
I hope it works for you too!
That looks a lot simpler than a bunch of posts about PowerShell that I found on the world wide wacky web. I will give it a try and will let you know if I get the required result on my end.
In the PowerShell script the Path parameter can take a comma separated array of separate files or folders.
It may be useful to add an exit command to the batch file to close command window.
There's also an Expand-Archive command that unpacks an existing archive.
as discussed by mail I made a small sample script, which is available here (http://practice-innovation.de/Downloads/call_powershell_script.zip) (link is not persistent, so hurry up ;-))
You need to create the batch file in your ES and when written, call it with File.execute().
(dynamic Batch is necessary, as you can’t pass parameters to File.execute())
PowerShell-Script takes two parameters (Source-Directory and Zip-FileName). Make sure ZIP files doesn’t exist, before calling the batch, otherwise script throws an error.
Hope this helps