HTTPS request in nsi script - https

Is it possible to perform an HTTPS request to my domain using a .nsi script for NULLsoft?
I've tried to use NSISdl::download_quiet /TIMEOUT=50000 "hxxps://example.org" "C:\Users\me\Desktop\config.ini" but seems that it doesn't work...
Does InetC support this? I've tried it but with no result...

Yes, INetC uses the same web library as Internet Explorer and it supports HTTPS.
Page Directory
Page InstFiles
Section
CreateDirectory $InstDir
inetc::get "https://example.com/myfile.ext" "$InstDir\myfile.ext" /END
Pop $0
DetailPrint $0 ; "OK" if successful
SectionEnd
You can add the /WEAKSECURITY switch if the server is using outdated SSL certificates.

Related

NSIS v3.08 and nsUnzip

I am trying to use the NsUnzip plugin with v3.08 of NSIS, but I keep getting a result code of 9 on all calls used in the "nsUnzipTest.nsi" when I use v3.08. I added the DLL file to both the "z86-ansi" and "x86-unicode" folders. I even tried adding the "Unicode true" to the NSI script, and it still gave a result code of 9. Since a code of 9 is "The specified zipfile(s) was not found", I went ahead and added a FileOpen and FileClose using the same path. FileOpen worked fine.
I changed back to NSIS 2.46 and the plugin worked without issue.
What could I be missing?
It does not look like that plug-in supports Unicode. In NSIS 3 you would have to add Unicode False to the top of your .nsi.
You could try re-compiling the plug-in yourself or try contacting the author...

Invoke-WebRequest not downloading proper exe file

Using Powershell version 4.0 I'm trying to download Firefox browser programatically:
$uri = "https://www.mozilla.org/en-US/firefox/new/?scene=2"
$out = "C:\Users\bhatsubh\Downloads\Firefox Setup Stub 48.0.2.exe"
Invoke-WebRequest -Uri $uri -OutFile $out
But it is not downloading the correct file. Instead the file is the wrong one with a size of 65 KB.
When I copy-paste the URL in the web browser the download starts automatically and the correct file is downloaded with a size of 237 KB.
The site uses javascript to start the download, so the wrong file you're getting is actually HTML page. Looking at its source we can see the actual link of setup "stub":
https://download.mozilla.org/?product=firefox-stub&os=win&lang=en-US
It's also possible to download the full installer:
https://download.mozilla.org/?product=firefox-latest&os=win&lang=en-US
Here is the solution for you:
Use this command: Invoke-WebRequest $URL -OutFile 'c:\local-name.exe'
The problem is with your URL. The url you are using is not the exact one pointing to original exe.
So For getting correct URL, follow below steps
Start downloading required exe and cancel that download in Chrome Browser
Goto downloads and right-click and click "Copy link adress" and set that value to $URL varible and retry. This works in most of the cases.

Why can't download the magnet with aria2c command?

The Battlestar Galactica here
http://kickasstorrentsan.com/usearch/Battlestar%20Galactica/
can be downloaded with deluge.
Now i scrap the magnet with firebug on the web page.
It can be verified that the magnet is :
magnet:?xt=urn:btih:2D2CAE6AC83800490327547053597BAFF6701C2F&dn=battlestar+galactica+season+1+s01+1080p+bluray+x265+hevc+aac+5+1+joy+utr&tr=udp%3A%2F%2Ftracker.publicbt.com%2Fannounce&tr=udp%3A%2F%2Fglotorrents.pw%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80%2Fannounce&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce
The bash script were written as following:
1.the $url variable is right address for magnet.
2.aria2c command can be executed correctly.
3.aria2c $url has beeen executed for about one hour.Why nothing can be dowlonaded?
This page says, you need to enable DHT option while downloading using magnet-links:-
This official documentation page says, it is enabled by default from version 1.25.0
--enable-dht[=true|false]
Enable IPv4 DHT functionality. It also enables UDP tracker support. If a private flag is set in a torrent, aria2 doesn't use DHT for that download even if true is given. Default: true
Checked the release notes from GitHub, couldn't find the exact release since the flag --enable-dht has been made to true.
Upgrade to the latest version to have the flag enabled by default (or) enable it explicitly if you are using an older version.
aria2c --enable-dht=true "magnet:?xt=urn:btih:2D2CAE6AC83800490327547053597BAFF6701C2F&dn=battlestar+galactica+season+1+s01+1080p+bluray+x265+hevc+aac+5+1+joy+utr&tr=udp%3A%2F%2Ftracker.publicbt.com%2Fannounce&tr=udp%3A%2F%2Fglotorrents.pw%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80%2Fannounce&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce"

How to add URL to IDM by program

How to add URL to IDM by program ? I am trying to develop a software what to add URL to the IDM. I have no idea how to do that could help me ? I found this temp folder C:\Users[USER]\AppData\Roaming\IDM\DwnlData but no idea how to add URL.
You can add links to IDM by passing the "-d" argument to IDMan.exe
From in your program or script, (you can use ShellExecute or the equivalent in whatever language you're using,) call [IDM Install Path]\IDMan.exe -d [link]
[IDM Install Path]: The directory where idm is installed
(eg. C:\Program Files\Internet Download Manager)
[link]: The url you want to add to IDM
enter link description here
Let us know if there is anything else we can help u with

How do I set up TeamCity CI so that it unpacks Xamarin components?

In Visual Studio everything works and a Components directory is created with the appropriate dlls. However, TeamCity is not able to retrieve the Android Support Library dlls because the trigger for the restore is a Xamarin VS plugin that runs when loading the solution. The equivalent of nuget package restore for Xamarin is xamarin-component. I have placed the xamarin-component.exe in my C:\Windows directory. To configure TeamCity, I prepended a Command Line build step with
Command executable: xamarin-component
Command parameters: restore mysolution.sln
TeamCity runs as NT Authority\System. So using PsExec,
psexec -i -s %SystemRoot%\system32\cmd.exe
If I then run 'xamarin-component login'
INFO (login): Computed cookie jar path: C:\Windows\system32\config\systemprofile\.xamarin-credentials
INFO (login): Computed cookie jar path: C:\Windows\system32\config\systemprofile\.xamarin-credentials
INFO (login): Credentials successfully stored.
When I go to my solution in cmd and attempt the restore, I get an attempt to download the componet, and then a Json parsing error. This is the same error I get in TeamCity.
I get the error if I use 'Administrator' (which stores the credential in C:\Users\Administrator. Earlier when I was using my personal account, it did work. However, once I deleted the C:\Users\tim\AppData\Local\Xamarin\Cache\Components, the same issue emerged. Fiddler shows that rather than getting Json back (as we do when we enter an invalid token) we are getting a 302 redirect that says Object moved here. And here is the xamarin
login page - obviously not Json.
Tried.
1. Set COOKIE_JAR_PATH to C:\Users\tim.xamarin-credentials - xpkg picks up but same error
2. Copy .xamarin-credentials from Config\system32 to D:\, set COOKIE_JAR_PATH to D:.xamarin-credentials - xpkg picks up but same error
3. Move .xamarin-credentials to C:\, set COOKIE_JAR_PATH - same error
4. Re-login in NT Authority with COOKIE_JAR_PATH to C:.xamarin-credentials - same error
My temporary idea now is to figure out where the NT Authority xamarin-component looks for Cache and put the files there.
C:\Windows\system32\config\systemprofile\AppData\Local\Xamarin\Cache\Components\xamandroidsupportv4-18-4.18.1.xam
The version of my xamarin-component is 0.99 - for 100, we try harder...
I’ve had trouble actually getting the cookie jar to load correctly from the system32 path. I think this is a path virtualization issue that I just don't understand well enough to make heads or tails of.
I ended up adding an environment variable that the tool will read from (I'm its principal author at Xamarin :-) that specifies the cookie jar path to read from, and this solved the problem for others using TeamCity. The environment variable is COOKIE_JAR_PATH.
You can set it from TeamCity's environment settings to point to a cookie jar path outside of the system32 profile directory (I think in my original testing, I put it in the root of the C: drive, but it can be anywhere, really).
As a hack, I copied the Cache folder from
C:\Users\tim\AppData\Local\Xamarin
to
C:\Windows\system32\config\systemprofile\AppData\Local\Xamarin\
That bypassed communication with the Xamarin server.
Update. I suspect it might be a bad link or setup on their server side. When xamarin-component restore is called, a call is made to
GET /api/available_versions?alias=xamandroidsupportv4-18 HTTP/1.1
which returns "Object moved to here" where "here" is nowhere.
If you start Visual Studio after deleting the Cache and Components folder (next to the solution), Xamarin makes a call to
GET /api/download/xamandroidsupportv4-18/4.18.1 HTTP/1.0
which has a similar looking Object moved to, but this time it directs you to xamarin-components.s3.amazonaws.com/
GET /fdca922d2b77799fe208a08c9f3444fe/xamandroidsupportv4-18-4.18.1.xam HTTP/1.0
Perhaps something changed, or the available_versions API has changed.
Thanks very much for this question and your answers to it. I didn't really like the idea of storing an auth cookie on the build node or having to copy a cache there manually, so I came up with my own solution so I hacked around this problem with a quick Powershell script that mimics the behaviour of the xamarin-component.exe restore action:
param
(
[Parameter(Mandatory=$true)]
$authCookie,
[Parameter(Mandatory=$true)]
$componentDirectory,
[Parameter(Mandatory=$true)]
$project
)
[void]([System.Reflection.Assembly]::LoadWithPartialName('System.IO.Compression.FileSystem'))
$xml = [xml] $(cat $project);
$components = $xml.Project.ItemGroup.XamarinComponentReference | ? { $_.Include.Length -gt 0 } | % { $_.Include };
if (!(test-path $componentDirectory))
{
echo "$componentDirectory didn't exist, so it was created.";
[void](mkdir $componentDirectory);
}
foreach ($component in $components)
{
$source = "http://components.xamarin.com/download/$component";
$destination = "$componentDirectory\$component.zip";
if (test-path $destination)
{
echo "$destination already exists, skipping...";
continue;
}
echo "Downloading $component from $source to $destination...";
$client = New-Object System.Net.WebClient
$client.Headers.Add([System.Net.HttpRequestHeader]::Cookie, "XAM_AUTH=$authCookie");
try
{
$client.DownloadFile($source, $destination);
}
catch
{
# The error message will be on one of these lines hopefully:
write-error "Failed to download! Errors are below:";
write-error $_
write-error $_.Exception
write-error $_.Exception.InnerException
write-error $_.Exception.InnerException.InnerException
exit 1;
}
if (!(test-path $destination))
{
write-error "$destination doesn't exist - the download must have failed!";
exit 1;
}
echo "Decompressing $source to $componentDirectory"
[System.IO.Compression.ZipFile]::ExtractToDirectory($destination, $componentDirectory)
echo ""
}
echo "Done!";
The -authCookie parameter can be extracted from either the XAM_AUTH cookie in your browser or from the .xamarin-credentials "cookiejar" in your home directory. It's nice to have it parameterised like this so you can store it as a secret variable in TeamCity.
The componentDirectory parameter must be the full path to the component directory - it will be created if it doesn't exist.
The project parameter should be the path to your project that you want to restore packages for - if you have multiple projects that need this then you'll have to execute the script for each one. Don't specify your solution as it won't work.
Unfortunately, this isn't very resilient to Xamarin's whims - a simple API change could render this useless, so obviously the best solution is to wait for Xamarin to fix this. I e-mailed Xamarin support to complain about this problem but I don't imagine I'll get a timely response (they seem very very busy these days). I hope this is useful!
Create directory and put that directory path in environment variable XAMARIN_CACHEPATH

Resources