how to open downloaded excel file when complete download in asp .net - javascript

We have a web server, which allows the user to download files (excel), which are dynamically-generated We'd like when a download has completed then it should automatically open client side in the excel.
is there any way to do so by asp.net code or jquery code or javascript code?

Nope. You can't tell the client-side how to handle downloaded files.
Imagine the security issues that would cause.
"you just (accidentally?) downloaded someShiftyFile.pdf.exe, now we MAKE your pc run it!"
Possibilities like that would make virus coders very happy.

Related

How do I open a program that is installed on the desktop from a web page?

someone knows how to open a program that is installed on the desktop from a web page, something like the onedrive option where from the web you can tell them to open a document and open word with that document or like when you open a torrent link ?
You basically have to download a file that is recognized by the program you wish to start. That program has to be pre-installed on the machine. The file should include instructions the program understand, and can execute.
In any case, this is quite fragile, and depends on many variables you have little control over, including the user, who might decline the download, or just save the file without opening it. So you should try a different approach to achieve what you want, than running a program on a user's computer.

Silent dowload using jQuery and Javascript

How can I make an HTML page and have it do a silent(!!) download of a file to a path on my Windows machine?
I want that, as soon as my Windows computer goes to this web page, it to automatically download the file of my choosing from my server to C:\Program Files, for example. This would be all on my private network.
So my aim is, if I have a file called target on the server, to download it to C:\Program Files, all through this webpage.
How can I accomplish this?
I have something like the following in mind:
Download Here
$('a').click... //Some jquery to download the file
I'd prefer to do it just with HTML and Javascript, since I'm not so fluent in jQuery.
Thanks in advance guys :)

Invoke a .bat script from HTML page

I've written a software that customers will install on Windows Server, and I wrote a HTML page for installation guide. How do I create a link on HTML page that will invoke my .bat script as an administrator. The .bat script will handle installation for customers. HTML page will be run as a file, that is without any server (including local host). The .bat script, html page, and binary will be in the same folder. The folder could be anywhere on the Windows server (I don't know where customers will place the folder).
One way of doing this would be to use a combination of AJAX and a script to accomplish this.
I'm going to assume the use of jQuery and PHP (just because they're so common) for this example.
jQuery just makes it shorter and this functionality will be available in most/all languages.
Let's say you have a page like this:
<html>
<body>
<a id="foo" href="#">Install</a>
<script src="install.js"></script>
</body>
</html>
And your javascript looks like this:
$("#foo").on("click", function(){
$.post('install.php');
});
In your install.php file, you could have this:
<?php
exec("mybatch.bat");
or
<?php
exec("cmd.exe /c test.bat");
However
Please note that what you are wanting to do has security problems.
Only do this if you are sure the environment is a secure one.
Running as administrator
This is a very difficult thing to do without cooperation from the client computer.
You more or less have to be running PHP or whatever language is installed locally as administrator.
Also, if running a batch file from a POST request is a bad idea, running a batch file as administrator is even worse. Avoid this.
In internet explorer:
file://mydirectory/myfolder/mybatchfile.bat
Most browsers don't allow this functionality because it poses a huge security risk for a link on a web page to be able to run local files. Most of them have extensions that disable that security feature. I haven't tested any of them to see if they work, however.
Even when this happens, however, the .bat run will happen like a download. The browser will "download" the .bat file, then give the user the opportunity to save it or run it. Unless your batch file is doing the administration elevation within the file itself, the user will have to manually run it as administrator.
Please keep in mind that these safeguards exist for a reason, and going around them is not a good idea. At the end of the day, however, there is no way to make the browser execute that code on its own. (Thankfully so!) There are better ways of accomplishing these kinds of tasks.
If you wanted to provide more details on what you are trying to accomplish, i'm sure we could come up with a more secure of doing what you want to do.

Download multiple files from remote server with a single user confirmation

I have a web page containing a list of pictures urls (can be more then 1000 items) and I want to enable a button for the user to click and download all of the files to the local hard drive.
The download process should ask the user for a directory to save the files in and then go ahead and download all files to that directory (if possible, creating sub directories inside). This should be done with a single user confirmation for the whole download process and avoid display the browser save dialog for each file.
Is there a way doing that? I am aware I can't use the standard HTTP protocol for the downloads and have to write some kind of control to do the job. The page is written in asp.net.
Downloading to the server, packing and sending to the user is not possible. The download has to be originated from the client machine.
You should update your question to include the requirements from your comment, because they make a huge difference. If the server cannot retrieve the files, because he doesn't have the right permissions, your only option is to run the code on the client side. There are several options how to do this, mostly depending on the clients and your coding skill:
Flash (Not sure about the security aspect of writing to the local file system, though)
Java Webstart (Disadvantage: Clients need to have the Java runtime installed)
Browser plugin/extension (Disadvantage: You can only support a subset of browsers and the page will not be immediately usable, as the plugin or extension needs to be installed first)
In all cases, you will have to write a tool, that retrieves the URL list from your server and starts downloading it.

Adding cash register support to ASP application. Starting an exe from client side

What I want is to print from a cash register from an asp application, what this basically means is to call an exe file that operates directly with the cash reigister with the txt file to be printed. A more correct formulation of this problem can be found on this link .
The solution given there are the following three:
Using a link pointing to exe file - an exe file is downloaded and it operates
the driver.
Using a resident program on the client computer listening on a port - the server
connects to it and operates the driver.
Using an ActiveX Object - the driver is operated by client script from the
internet browser.
I want to do this not using any resident program, but directly from the browser. In that respect I found a solution in Java using Applets, which is fine, but I have to do it with ASP.NET, and the only way I can do that is by using an ActiveX Object, and the problem with the is that they only work on Internet Explorer, which is not an option.
After thoroughly searching the internet my problems ca be concentrated in the following question: How ca I run an exe from client side on any browser without using ActiveX Objects?
I know that this questions was posed thousands of times, but is there any plug-in, loophole, some form of java applet from an asp page :), anything that can help me solve this problem?
UPDATE:
Thanks for the comment and answer. The solution we finally choose is than whenever a printing request is formed the main asp application updates the database with that request and a resident application scans the same database for changes and creates and prints the txt.
Luckily it is not possible (imagine the security issues if it was possible).
However, you still have some options:
Offer the .exe to download. This is the most portable way
Use a .NET ClickOnce setup. This will start an installer with a single click in IE and browsers which have the ClickOnce extension enabled. In other browsers it will provide you with a setup.exe download.

Categories