assign .zip file to link

Hello Experts,

I created an ASP.NET application that retrieves a list of printers on a certain network subnet which works fine. I have it setup so when the user clicks on a link it calls a .bat file to execute (install the printer via cmd line). However this will not work with FireFox, Opera, and a few other because of known security risks.

So what I would like to do now is include the .bat file inside of a .zip folder so that when the user clicks on the link that points to \\backup\printerdrivers\ that it will prompt the user to either "Open" or "Save" the file to their desktop. Is this possible and if so how.

I'm using ASP.NET 4.0 and C#.

Thanks in advance!!!
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

what's the difference between linking the bat file and zip? it'll be the same sort of linkage.
just zip your bat file and point to it. you'll be prompted to save it and then do whatever you like
Mark FranzProject ManagerCommented:
The first thing you will have to do is create the .zip file.  This should help;

Check out DotNetZip,

You can use GZipStream too;

public static void Compress(FileInfo fi)
        // Get the stream of the source file.
        using (FileStream inFile = fi.OpenRead())
            // Prevent compressing hidden and already compressed files.
            if ((File.GetAttributes(fi.FullName) & FileAttributes.Hidden)
                    != FileAttributes.Hidden & fi.Extension != ".gz")
                // Create the compressed file.
                using (FileStream outFile = File.Create(fi.FullName + ".gz"))
                    using (GZipStream Compress = new GZipStream(outFile,
                        // Copy the source file into the compression stream.
                        byte[] buffer = new byte[4096];
                        int numRead;
                        while ((numRead = inFile.Read(buffer, 0, buffer.Length)) != 0)
                            Compress.Write(buffer, 0, numRead);

Open in new window

Once the file has been created, linking it should be a no brainer.
asp_net2Author Commented:

What is the difference from just manually zipping the files up and placing them in the files system for retrieval compared to the code you supplied?

I just need to be able to download the .bat file. Firefox will NOT run scripts from within their browsers for security reasons but IE will. So I thought it would be best to some how provide the user with the option to download the file.

I did include the .bat file into a .zip folder but when I provided the link to click on it did not ask me if I wanted to "Open" or "Save" the file. It appeared to be trying to open the .bat file instead.
Starting with Angular 5

Learn the essential features and functions of the popular JavaScript framework for building mobile, desktop and web applications.

hmm, that's interesting.
is there any setting in FF that prevents files from just simple downloading? imho, the normal behaviour is to start downloading showing the progress in separate Downloads popup.
asp_net2Author Commented:

for some reason if I zip the file up I'm not promtped to Open or Save the .zip file.
can you use linking based on IP address rather than WNet name?

just trying to see if it makes any difference. also, have a look at your registry to get default behaviour for "zip" extension
asp_net2Author Commented:

Let me try this solution to see if IP link works. I'm currently using \\backup\printerdrivers\

Stand by :)
asp_net2Author Commented:

Yes, if I use the IP then it prompts me to Open or Save in both IE and FF.
ok, ip or hostname, it seems that the browser treats it as URI and offers you to save it, while network path is interpreted as 'command line' sort of thing.

alternatively, you probably could register your own custom scheme (like http) but it's too much hassle I reckon.
asp_net2Author Commented:
How would I do what you mentioned below?

>> alternatively, you probably could register your own custom scheme (like http) but it's too much hassle I reckon.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mark FranzProject ManagerCommented:
Check the MIME types that your host allows, if it does not allow .zip files to be sent you will get the kinds of issues you are running into.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.