Windows command+ Browser bookmark - windows

Kindly help is there any command to access browser bookmark via command line and open the bookmarked URL's via command line or powershell or wmic.
Also is there any event in windows which tells when a bookmark was accessed.
Thanks in Advance.

Generally speaking, there is no event to let windows know that any browser executed or accessed a bookmark.
Normally the bookmarks are stored inside a file like "bookmarks.adr" or similar which contains all the information the browser has about the stored bookmarks (except thumbnail or favicon data). If you want to access the URLs and open them, you need to parse the bookmarks file and extract the URLs. Doing this on the commandline with batch only is tricky at least... unless you just need something simple like a findStr on http which would extract all those URLs beginning with http (check out findStr /? and type /? and try something like type bookmarks.adr | findStr http > urls.txt which needs to be processed further with a for loop maybe (check out for /? on the commandline).
PowerShell might get the job done more easily but I don't know about the specific format of the bookmarks file and the browser you target. The browsers have their own format and thus the parsing is different for each browser class (maybe it is more unified than I am aware of, since most browsers are based on Chromium nowadays and therefore certainly share the same bookmarks file format).
Hope this helps. Good Luck with your project :)

Related

Open URL from Terminal without "http://" prefix

This might be a stupid question, but I will ask it anyway. When I try to open a URL (like google.com) from Terminal using the open command, I get the following error:
The file /Users/jack/Desktop/google.com does not exist.
Perhaps you meant 'http://google.com'?"
How can I open "http://google.com" without having to use the http:// prefix?
I'm having a difficult time interpreting your question, so this might not even answer your question.
TL;DR;
As far as I am aware, there is no way to do what you are asking. It is possible that there might be a third-party application out there somewhere that will do roughly what you want, but I am not aware of one off the top of my head.
The longer answer
The problem here is how your OS processes your request. When you say "open {name-of-something}, your computer opens the "something" with its default application. For example, on MacOS, a .txt file might get opened with TextEdit.
However, you can also define the protocol with which you want to open your "something". In the case of URLs, you are opening the URL using the http protocol. Your computer knows that anything with the http:// protocol prefix gets opened in your default web browser (and then your web browser handles it from there). When you do not add the http:// prefix, your computer doesn't know that you want to open "google.com" with the http protocol, so it thinks it's just a file.
Bottom line, you must have the http://.
Disclaimer to computer geeks: I apologize if this is not the best explanation. I'm self-taught, so some of my vocabulary might be a bit off.

Bat file to open webpage with parameters to local file

Creating a bat file with:
start http://www.google.com/search?q=test
Does just what I would want it to do, it opens my default web browser (Chrome in my case) and browses to the URL http://www.google.com/search?q=test.
However, a bat file with:
start file:///C:/Users/d92495j/Desktop/OracleCDs/WebLogic/template.html?wbt=1
Only opens my default browser and browses to file:///C:/Users/d92495j/Desktop/OracleCDs/WebLogic/template.html
Note the lack of ?wbt=1. In order to fix this I've tried:
URL encoding the question mark
Running the start command parameters "window name" "file path in quotes"
Putting the file path in
variable and passing the variable to start
But none of those work. How can I get this to work?
I tested this and got the same result. I'm not really sure, but I guess this belongs to the question mark. The local file system of Windows can never have file names with ?, because this is a "wildcard" like *. I think it is possible that the file name is truncated there.
The following codes also doesn't work or produces only error messages:
start "file:///C:/Users/d92495j/Desktop/OracleCDs/WebLogic/template.html?wbt=1"
start file:///"C:/Users/d92495j/Desktop/OracleCDs/WebLogic/template.html?wbt=1"
The best solution I've come up with so far is:
powershell -noprofile -command "[void][System.Diagnostics.Process]::Start('chrome', 'file:///C:/Users/d92495j/Desktop/OracleCDs/WebLogic/template.html?wbt=1')"
This solution has the batch file launch PowerShell and then use the .NET System.Diagnostics.Process.Start method to launch Chrome with the correct parameter. The only downside is that it makes a browser choice for me and I'd prefer it to use my default browser, but I can live with that. I'll accept another answer (that is not much more complex) that uses the default browser.

How do I make Firefox open a file with an ampersand in the filename?

I've written some Ruby code to inspect ZIP-files as part of an internal company process. The way we usually launch this code is from a web browser. When you click to download the file, you select "open with" and specify the full path to a small batch file. This one-line batch file looks like this:
\\mathworks\public\Matthew_Simoneau\ruby-1.8.7-p72-i386-mswin32\bin\ruby.exe "%~dp0inspect.rb" %1
As far as I know, this technique is the only easy way to launch my Ruby code on a Windows machine which doesn't have Ruby installed, but does have access to the company internal filesystem.
I'm having a problem when the filename of the ZIP file contains an ampersand.
This works fine on IE and Chrome, where the above line gets "expanded" out to the following:
C:\WINNT\Profiles\matthew\Desktop>\\mathworks\public\Matthew_Simoneau\ruby-1.8.7-p72-i386-mswin32\bin\ruby.exe "\\mathworks\public\Matthew_Simoneau\sandbox\inspect\inspect.rb" "C:\WINNT\Profiles\matthew\Local Settings\Temporary Internet Files\Content.IE5\VNATJ3X0\park&park_paper_LMI_neuralN[1].zip"
On Firefox, however, everything after the ampersand in the filename gets dropped on the floor:
H:\>\\mathworks\public\Matthew_Simoneau\ruby-1.8.7-p72-i386-mswin32\bin\ruby.exe "\\mathworks\public\Matthew_Simoneau\sandbox\inspect\inspect.rb" C:\Temp\park
I've tried putting the %1 in quotes in the batch file, but that has no effect.
I suspect this is a bug in Firefox. I've searched the Firefox bug list, but didn't find anything.
Am I doing something wrong here? Is this a Firefox bug? If so, is there a way I can work around it? Is there a more robust way to launch my Ruby code from a web browser?
Update: I filed a bug report with Bugzilla#Mozilla, but there hasn't been a response yet.
Since you apparently have no control over the zip filenames, you could do the following in the Ruby code...
If the filename passed does not exist, look in the same folder for any file with the base passed filename followed by "&*.zip".
This will work for "park&park.zip" as long as there isn't also a zip file already in the folder named, say, "park&foo.zip".
If there is a real potential for filename collision (i.e., the zips aren't being cleaned off the user's machine and ampersands are common), the only other solution might be using a download manager plug-in in Firefox that has filename re-writing capability to fix any ampersands on the way down.
I've just tested something similar with Firefox 3.5.2 on Linux and it works well (i.e. shell script gets the correct path).
You should first try to use a script like that:
echo %1 > c:\temp\test.txt
(hope that's the right syntax, I didn't use cmd for a long time)
…and see if you get right path in that file. If the ampersand is stripped in that file too, and you're using the latest version of Firefox, that means you found bug specific to Windows platform and you should report it.
Use %24 for the & character. See the URL Encoding Table for other such problematic characters: http://webdesign.about.com/library/bl_url_encoding_table.htm
Encode your ampersand for best results...
&
As in
C:\WINNT\Profiles\matthew\Desktop>\\mathworks\public\Matthew_Simoneau\ruby-1.8.7-p72-i386-mswin32\bin\ruby.exe "\\mathworks\public\Matthew_Simoneau\sandbox\inspect\inspect.rb" "C:\WINNT\Profiles\matthew\Local Settings\Temporary Internet Files\Content.IE5\VNATJ3X0\park&park_paper_LMI_neuralN[1].zip"

how to let ruby call default browser to open localfile

In this question, I find that using system('start http://www.google.com') is OK. If the file is in local disk, though, using system('start file:///c:/temp/a.html') doesn't work. How do I have Ruby get the default browser to open a local file?
What do you get when you double click a .html file in Windows Explorer? If it isn't the browser then that is your problem. The 'start' keyword pushes the path through the ShellExecute function, for http:// URLs is knows to open that in a browser, if it is a file it depends on the extension of the file, if your system has .html pointing to notepad for example (because in the past you have set it to notepad) it is always going to open it in that program unless you go and specifically change it.
From a generic work around point of view there is not much you can do, if you can access the Windows registry under Ruby then you can query the HKEY_CLASSES_ROOT\http\shell\open\command default value which contains a command line for the current browser bound to the HTTP protocol, you could use that to construct a full path (replace the %1 with the URL string).

How to get the last current or visited Web URL in Windows?

I'm writing a Windows app. where you can create "links", it is easy to link files or folder (just use the standard dialogs for open files or browse folders), but for linking a Web URL I don't know how to get (from a Windows function or registry key) the current or last visited page.
Maybe something like the recently used files, but referencing web pages (independent of the browser), could be useful.
There is no common browser independent place to look for the last visited pages from what i know(i'm saying this from my experience at computer forensic)
I know there is a place in the registry where explorer saves this info, and probably other browsers as well, you can find this info by using a tool like procmon by sysinternals.
Just enter a site and see what the registry writes down..
This might give you a start:
wrapper class for URL history interface in C#
I found it! (at least for IE)...
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\TypedURLs
Then, I should find the equivalent key (or maybe a config file) of the other most common web browsers.

Resources