At local machine, How to zip a file at remote location using scripting in batch file

Dani AI

Generated

Briefly: there are three practical ways to make a local DOS batch file “zip” something that lives on a remote machine — which one to use depends on what the remote host exposes and what you can install there.

If you can run commands on the remote machine (recommended): invoke a command-line zipper on that machine from your batch file. On Windows this is commonly done with PsExec or PowerShell Remoting; on Unix/Linux use SSH. Example (PsExec + 7‑Zip):

psexec \\REMOTEHOST -u DOMAIN\User -p YourPwd "C:\Program Files\7-Zip\7z.exe" a -tzip "C:\path\archive.zip" "C:\path\file.txt"

If you can only access the file via a network share: map the share in the batch file, run a local CLI zip tool against the mapped drive, then unmap. Example:

net use X: \\REMOTEHOST\share /user:DOMAIN\User YourPwd
"C:\Program Files\7-Zip\7z.exe" a X:\archive.zip X:\file.txt
net use X: /delete

If neither remote execution nor shares are available: transfer the file locally (FTP/SCP/SMB), compress it locally, then upload the archive back. This is slower and uses bandwidth but works when remote execution is not allowed.

Notes and gotchas (from the thread): ’s remote-command idea is valid but avoid plain telnet — prefer SSH/WinRM/PsExec for security. As implied, a compressor must run somewhere (remote or local). Watch permissions, file locks, UAC, and firewall rules; test with a small file first. Avoid storing plain-text credentials in scripts; use scheduled tasks or machine accounts where possible. Log return codes from the zipper tool so your batch can detect failures.

Recommended Answers

All 13 Replies

Are you talking about a DOS batch file?

Yes, its DOS Batch

You will have to use whatver zipping tool is installed on the remote machine if you want to zip the file while it still resides on the remote machine.

At local machine, How to zip a file at remote location using scripting in batch file

if your remote system runs telnet, you can use the Perl's telnet module to telnet to remote system, gzip the file and return to calling script.

If you want to use a batch file (or even telnet) why are you asking in the perl/cgi forum?

Now that's the question you should be asking...

Stop Spamming

Who's Spamming?

I think masijade has been smoking something:

http://www.daniweb.com/techtalkforums/thread49624.html

No, yesterday there was a large advertisement for someones site selling all sorts of scripts. Seemingly it has now been removed (either by a moderator or the individual who posted it).

But I wouldn't mind a little smoke, and Amsterdam is not far away.

As a mod I should see those "deleted" posts..... hmn, maybe you need to post a hijack this in the spyware, viruses, and nasties section!?

The same advertisement was also in this thread

http://www.daniweb.com/techtalkforums/thread49624.html

but has also since been deleted/removed/whatever.

Also, as you can see, both in the reply above and the one in the other thread, the "subject" line is "website design" and not the title of the current topic. I did not change the subject line. I am not sure what he did to your site to place and then remove the advertisements, but they were there.

No, yesterday there was a large advertisement for someones site selling all sorts of scripts. Seemingly it has now been removed (either by a moderator or the individual who posted it).

Sure there was. :rolleyes:


hehehe... just kidding, makes sense. I hate spammers too so if I see this creep I'll make sure to let them know spammers are the lowest form of life on earth, just below child-molesters and rappists. :mad:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.