How to send multiple links to IDM (Internet download manager)? - command-line

I'm trying to send a couple of links to IDM like what it's extension does on browsers, but I don't know the command line related to it. All I know is that I can send a single link like this:
string idmpath = #"C:\Program Files (x86)\Internet Download Manager\IDMan.exe";
string file = " /d "+"https://www.website.com/file.rar";
System.Diagnostics.Process.Start(idmpath, file );
But I don't want to send a single link. I'm going to send a couple of links like what IDM extension does in browsers:

Related

PowerShell, Download from OneDrive (*not* Business)

Programmatically downloading from Dropbox with PowerShell is trivial. With a link to a shared file https://www.dropbox.com/s/sdfjjthwrf32yFileName.pdf?dl=0, you just replace www.dropbox.com by dl.dropboxusercontent.com to give https://dl.dropboxusercontent.com/s/sdfjjthwrf32yFileName.pdf?dl=0 and can then use Invoke-WebRequest to fetch that file via a script (as long as the permissions on it are open for anyone to read).
With OneDrive, I have spent a few hours looking, and found no way to download a file with PowerShell. Some websites talk about OneDrive for Business, this question is not about OneDrive for Business as I do not know about or use that, this is specifically about OneDrive.
What I want to do is really simple, i.e. share a file in OneDrive, then get the share link, then be able to programmatically download that file using PowerShell (as the file is set to "anyone can view" so I should not really require authentication). Here is how I would share that file on the OneDrive.live.com site:
I then change the file from "Anyone can Edit" to "Anyone can View", and this gives me a link that looks like this:
$url = "https://1drv.ms/u/s!Bjfhd-pwUc_asdcadfasdfTYFASDFASDf?e=aksdHDG"
I then try to download it using Invoke-WebRequest:
Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile "C:\MyFile.txt"
But all I get is a small stub of javascript output (note that the above is not a real link, but an example)
With Dropbox, it is trivially simple, so how can we do this with OneDrive?
The closest I have come might be the OneDrive module, but I don't know how to generate an OAuth2 token that I can pass to the script (and it completely breaks the purpose of this exercise, as if I have to provide credentials to download an "Anyone can View" file, then I cannot create a script that others can use to download a file without them also providing credentials; we should not need to provide credentials if the file in question is set as "anyone can view". That is the case for the Dropbox example; if the file is to read-only for everyone, then no credentials are required, as that would obviously be sort of ludicrous - it would be like demanding a key to get through an unlocked and open doorway that has a sign above it saying "Anyone may freely enter here without a key").
Install-Module -Name OneDrive -Force
Please note: To stress, this question is not about OneDrive for Business, that is something that I do not know or use.
You can download the shared file directly by using the OneDrive API. To do so, you have to convert your sharing URL into a sharing token and pass it to the OneDrive API. This example shows the needed C# code. You can derive the following PowerShell function from it:
function Get-OneDriveDirectDownloadUrl {
param(
[string]
$SharingUrl
)
$base64Value = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($SharingUrl))
$encodedUrl = 'u!' + $base64Value.TrimEnd('=').Replace('/','_').Replace('+','-')
return 'https://api.onedrive.com/v1.0/shares/' + $encodedUrl + '/root/content'
}
With that function, you can convert your sharing URL like this:
Get-OneDriveDirectDownloadUrl -SharingUrl 'https://1drv.ms/u/s!Bjfhd-pwUc_asdcadfasdfTYFASDFASDf?e=aksdHDG'
And you will receive the following direct download URL:
https://api.onedrive.com/v1.0/shares/u!aHR0cHM6Ly8xZHJ2Lm1zL3UvcyFCamZoZC1wd1VjX2FzZGNhZGZhc2RmVFlGQVNERkFTRGY_ZT1ha3NkSERH/root/content

Sending email attachments via UWP EmailManager not working

Sending an attachment from a universal app with the following code is not working, why?
Dim emailMessage As New EmailMessage()
emailMessage.[To].Add(New EmailRecipient("a#b.com"))
emailMessage.Subject = "Test"
emailMessage.Body = "Hello World"
Dim localAppFolder = Windows.Storage.ApplicationData.Current.LocalFolder
Dim file = Await localAppFolder.CreateFileAsync("SomeFile.txt", Windows.Storage.CreationCollisionOption.ReplaceExisting)
Await Windows.Storage.FileIO.WriteTextAsync(file, "aaaa")
Dim fileRef = RandomAccessStreamReference.CreateFromFile(file)
emailMessage.Attachments.Add(New EmailAttachment(file.Name, fileRef))
Await EmailManager.ShowComposeNewEmailAsync(emailMessage)
To, subject and body show fine in Outlook, but the attachment is missing: Outlook screenshot
I believe it is because the Outlook is a Desktop app. As I understood, the EmailManager.ShowComposeNewEmailAsync uses mailto: protocal to launch mail client app and use share to provide the email content.
If you choose the mail store app when the select default app dialog launches, you will be able to see the attachment as following:
If you have previously chosen Desktop Outlook app as the default as for mailto protocol, you have to change the default app for the mailto: protocol association in control panel .
Previously, the ShowComposeNewEmailAsync only works for windows phone runtime app. And it is not up-to-date in the document, because it doesn't include the win 10 support.
On Windows 10 mobile, it works well without any problem. But on Windows Desktop, you have to choose a store app.
This is still an issue in 2019, but I have found a workaround for my project.
I simply assemble an *.msg file with recipients, subject, body, attachments etc. and save it to the apps local cache folder. It can then be launched using Launcher.LaunchFileAsync
As *.msg files are associated with outlook, it will most likely be the default app to open this kind of file. You can create such a file using MsgKit
I have prepared a demo project at: https://github.com/Moolt/UniversialWindowsPlatform.LaunchOutlook

Intercept all emails sent from Xampp Mercury Mail Server

I have a Xampp Server that I use only in a development environment. In order to preview emails that would be sent from the live sites without actually sending them I would like to intercept all the emails sent from this server. I would like to be able to either send them all to a specific email or save them as files instead of sending them to whatever address they're set to go to. This way I can make sure they are correct without accidently sending emails during testing.
I found a similar question with an answer
here
but was unable to find a way to open any of the dialogs in the answer and so it didn't get me very far.
Thanks in advance for your help!
You can accomplish this using the sendmail configuration within your php.ini.
Create a file named smtp_catcher.php and the set the sendmail_path
sendmail_path = "php C:\path\to\file\smtp_catcher.php"
Then in your smtp_catcher.php add this block:
#!/Applications/XAMPP/xamppfiles/bin
<?php
# create a filename for the emlx file
list($ms, $time) = explode(' ', microtime());
$filename = dirname(__FILE__).'/'.date('Y-m-d h.i.s,', $time).substr($ms,2,3).'.emlx';
# write the email contents to the file
$email_contents = fopen('php://stdin', 'r');
$fstat = fstat($email_contents);
file_put_contents($filename, $fstat['size']."\n");
file_put_contents($filename, $email_contents, FILE_APPEND);
# open up the emlx file (using Apple Mail)
exec('open '.escapeshellarg($filename));
?>
Now I am not sure what extension you'll need to use to view the emails but this should catch all emails going out.
NOTE: make sure that php is in your window's environment PATH

Custom action button (Junk+)

Is it possible to create custom action button? ["Junk" button with more complex action]
I would like to:
mark the message as junk
copy the message to special folder common to all email accounts
move the message to per account junk folder
AFAIK Current junk button can deliver 1 and 3 without 2.
I need it for custom reporting to external services e.g. spamcop, knujon and other.
If thunderbird can not deliver such functionality then I am willing to accept suggestion of other Linux email clients capable to deliver such functionality.
Obviously this is easy to do with a custom XUL add-on and some basic Thunderbird chrome scripting.
This can also be done with the Custom Buttons Add-on for Thunderbird. Here is the code for the button, you will need to replace with your own folder URI's. The URI's for the folders can be accessed from the right-click content menu Properties .
/* Code */
// 1. mark the message as junk
goDoCommand("cmd_markAsJunk");
// 2. copy the message to special folder common to all email accounts
var copyUri = "imap://{user}#{host}/{path}/{folder}";
var copyFolder = GetMsgFolderFromUri(copyUri);
MsgCopyMessage(copyFolder);
// 3. move the message to per account junk folder
var moveUri = "mailbox://{user}#Local%20Folders/{spam folder}";
var moveFolder = GetMsgFolderFromUri(moveUri);
MsgMoveMessage(moveFolder);
The button script definitions are stored in the file:
{thunderbird profile}/custombuttons/buttonsoverlay.xul
You may be able to update this file automatically to ease deployment.
WARNING: Thunderbird 31 requires different code.
See https://bugzilla.mozilla.org/show_bug.cgi?id=1043819

Downloading files from google drive with rest API / c++

I have files in my google drive , very small ones, <10kB, and I try to download those by using downloadUrl , but the result only seems to be redirection to happen all the time. I have seen also discussions about that but no actual results ..
I am using c++ and creating rest API request by myself ( not using any libraries for this )
But also , when I copy the url I receive after continue="..." web browser can make a download okay but calling that from C++ seems to cause just another redirection to happen .
I followed the instructions from:
https://developers.google.com/drive/web/manage-downloads
This is probably a duplicate of Unable to retrieve file content from google drive API which states that the access token for downloading content needs to be set as an HTTP header.