Reading a web address in a batch file - batch-file

I can open a web browser using an address saved in a batch file. However, I am looking for a way to save the address when I close the window, without having to manually re-edit the file by hand.
I can read/write to a text file; the only part I am not figuring out is how to access the address of the open web tab. Is this do-able through a batch? Or do I need to take a different approach?

The web browsers save address information either in a file or in Windows registry from where it can be read by a batch script.

Related

Run a .exe file when a file is opened in a folder

I am mounting a folder as a virtual drive and i want to run a .exe file everytime user opens any file present in that folder. To be precise the folder would contain dummy files present on some other machine. By dummy files i mean the file would be listed but it would be a empty file. Whenever user opens a file i want the .exe program to download that file from another machine and display it to user.
That functionality (remote access on demand) can be implemented using reparse points and file system filters.
You could
use hooks to rewrite the jump address of OpenFile and in the
detour function check for the handle type, retrieve it's info by
using GetFileInformationByHandleEx, parse the data, download
what you need, open the downloaded file and then return
STATUS_SUCCESS or any appropriate error status in case one occurs.
Note
this is a bit more complicated as you also need a auto-inject
mechanism to inject function/library into each process according to
it's architecture.
this is not a safe procedure as most AV's will most likely consider your code malware.

How to find out if a pdf file is "blocked" by a pdf-reader

In our application you can import - for instance - a pdf file into the application area. In the popup window where you define the path of the pdf file, you can specify if the original file should be deleted after a successful import or not.
Sometimes a user imports a pdf file, which he has also "open" in an pdf reader (in our case pdf xchange viewer and foxit reader). In this case our application cannot delete the pdf file because it is somehow blocked.
How can I find out - for instance a winapi call? (without trying to delete it or rename it) that the pdf is blocked by a pdf reader?
Thanks alot in advance
Though it is not good to interfere with other programs (just tell your user the file is being used), releasing file locks are a bit difficult.
First, you need to use ZwQuerySystemInformation to obtain a system-wide file handle table (and your program needs SeDebug privilege) and find the file being used.
Use DUPLICATE_CLOSE_SOURCE flag for DuplicateHandle to duplicate and close the file handle.
Or, go into the kernel and use ZwClose or ObDereference functions to close a file.
Still, closing a file outside may crash remote programs and it is against Windows' design principles.

how to take path location from textbox and put it in batch

Hello guys im trying to make an extension that open any exe on user computer by simply textbox.user will write the path of exe he wants to open and i need to take that path to batch file and run it is that possible if that so how?
my current batch file only open one path but i want it to take paths from user and open that exe on path location
Well, Native Messaging does not allow you to pass command line parameters. It will only allow communication using the Native Messaging protocol (length + JSON-enconded message).
So you need to make a single native host that is able to read an incoming message, decode it and execute the command you want, i.e.:
// Extension side
chrome.runtime.sendNativeMessage('native.app.id.here', { command: "calc.exe" });
and then the app will receive, through STDIN, the length of the message + {"command":"calc.exe"}
Actually writing code that will decode that message using batch scripting is a terrible idea, but doable in principe. You should probably write an actual program in a language with support for JSON manipulation to handle this. See also this question.

How can I put a file path into the clipboard so that it can be pasted as file in a file manager?

I want the user to be able to copy a file that's stored on disk from my GTK application to a normal file manager like Nautilus. How can I do that? I would prefer to just write a path into the clipboard and let the file manager take care of actually copying, is that possible?
I just found an example in which it seems as if the actual file data is transferred through the clipboard – but is that the only possible way?
You need CF_HDROP and possibly other shell clipboard formats.
See: http://msdn.microsoft.com/en-us/library/windows/desktop/bb776902(v=vs.85).aspx;

Winforms csv file generation, want to generate file then ask user to save it or open it

When a user clicks on a button on the winforms application, I will generate a CSV file.
I then want to ask the user to either save the file to disk OR open the file.
How can I do that?
Note: I am just generating the file in memory, not writing it to disk until the user selects the path to save it to.
If you are looking to open this for the user in the default application for CSV on their machine, you will need to write it to disk to make it happen.
What I would do is if they want to save it, just save it to their location!
If they want to open it, save it to the temp directory, then use System.Diagnostics.Process.Start(path) to open it in the default application.

Resources