Tag Archives: AUTOMATION


#67 7zipExample Automation Application In C#

Example Video

While creating a download page for a website I came across the problem where the browser would open a .PDF file instead of downloading it to the desktop of my PC when using the JavaScript window.location.href = "url/path/file.pdf"; function. A quick easy solution is to archive the .PDF document as a .ZIP file or .7z etc. Now when the function is called the file will be downloaded.

Using a quick C# WinForms application I was able to automate the process. Here I have included a small demo project which may be useful on windows machines.

The Main function is as below:

Example code of the main function.

A new process is started and Arguments are sent to the 7za.exe console application.

7za.exe can also be used in the CMD console as well as with scripting languages such as PowerShell or Batch.



Custom batch file example

A batch file is a script file in DOSOS/2 and Microsoft Windows. It consists of a series of commands to be executed by the command-line interpreter, stored in a plain text file.

Batch scripts are used to automate redundant tasks such as creating 100 folders or updating 50 servers. Yes you could do this 1 at a time manually but this is inefficient and a waste of time and money + resources.

Example Batch script

A good well written batch file can get a lot done and makes our lives a hell of a lot easier. The Linux equivalent is called a shell script.

Typically batch scripts end with .bat and some with .cmd. Batch scripts are executed.