The above code doesn't work, or needs some extra stuff in the system the poster forgot to mention. It uses WScript vbs environment and several Shell objects. All were installed by default in Windows XP business? Perhaps they are longer there for Win8? But what would be the advantage to this approach? Why not just write the PowerShell script to a fixed file and let it accept parameters?
I tried all the other solutions. The most important advantage is use of powershell's native commands and no need to create the old-tech VBScript. This worked for me on an old corporate windows7 laptop in Can be run direct from CMD, no need to create. Here is a great link that shows how to zip a file using windows native commands. Community Bot 1. LostUser LostUser 27 2 2 bronze badges. You should include the instructions in your answer. If the links go stale, your answer will be worthless NameSpace target for each item in sourceFolderObj.
IsFolder then if item. CopyHere item ' wait until the file appears in the ZIP file, ' this is needed because CopyHere returns immediately after starting an asynchronous copy process ' starting multiple asynchronous copy will not work as it causes error messages, an invalid ZIP file, ParseName item.
Name is nothing WScript. Nice work; I've been in a situation a few times where I'm not allowed to run non-whitelisted exes, I'll keep this in my toolbox, with a small modification of an argument to overwrite or add to existing file.
This is an old question, but it's relevance is still current. Dwight Wilbanks Dwight Wilbanks 19 1 1 bronze badge. CreateObject "Scripting. NameSpace InputFolder. Items objShell. NameSpace ZipFile. ELinuxbook ELinuxbook 95 2 2 bronze badges. I assume that works on Linux, but it doesn't work on Windows. Of course, the OP didn't mention which operating system he was using.
Michal Sipek Michal Sipek 6 6 silver badges 17 17 bronze badges. The Overflow Blog. Stack Gives Back Safety in numbers: crowdsourcing data on nefarious IP addresses. Featured on Meta. New post summary designs on greatest hits now, everywhere else eventually. Visit chat. Linked Related Hot Network Questions. Question feed. Item 1 Wscript. NameSpace MyTarget. CopyHere winShell.
NameSpace MySource. Items do until winShell. Improve this answer. Community Bot 1. Stephen Jennings Stephen Jennings There is a single, simple cmd. Through PowerShell v5. I believe that Windows XP does have a built in function for this called Compact. That does not create a. Like I said you need to download the resource kit for 2k But you know upon further playing with it and its not very good.
I would highly suggest the user just bite the bullet and use a external program.. Search In. ZIP command line options in XP. Share More sharing options Followers 0. Recommended Posts. Posted August 23, Link to comment Share on other sites More sharing options JRosenfeld Posted August 24, Posted August 24, Digitalx Posted August 24, DOS's pkzip B too bad it lives on in windows 98 and not in xp.
0コメント