System cannot find path specified when installing .exe and .msi silently - windows

I am trying to install my .exe after downloading them into:
wget "https://github.com/git-for-windows/git/releases/downloadv2.13.1.windows.2/Git-2.13.1.2-64-bit.exe" -outfile c:\Windows\System32\Bradford\Git-2.13.1.2-64-bit.exe
However, when I try to install it silently, without human interaction:
C:\Windows\System32\Bradford\Git-2.13.1.2-64-bit.exe /s /v"/qn"
I am getting this error:
The system cannot find the path specified.
Also I do not know how to install a .msi file silently as well. In this case, nodeJS
I am using a AWS instance instance. Specifically:
Microsoft Windows Server 2012 R2 with SQL Server Express - ami-37b39552
Microsoft Windows Server 2012 R2 Standard edition, 64-bit architecture, Microsoft SQL Server 2016 Express edition. [English]

The easiest way I know how to do this is with Chocolatey.
I have some cloud servers that need various Chocolatey packages, and I do (something like) the following to install them. I have installed Git this way before, and it is a completely unattended / silent install.
Here's a short script that handles installing and configuring Chocolatey, installing Git, and updating the %PATH%.
<#
.description
Get the PATH environment variables from Machine, User, and
Process locations, and update the current Powershell
process's PATH variable to contain all values from each of
them. Call it after updating the Machine or User PATH value
(which may happen automatically during say installing
software) so you don't have to launch a new Powershell
process to get them.
#>
function Update-EnvironmentPath {
[CmdletBinding()] Param()
$oldPath = $env:PATH
$machinePath = [Environment]::GetEnvironmentVariable("PATH", "Machine") -split ";"
$userPath = [Environment]::GetEnvironmentVariable("PATH", "User") -split ";"
$processPath = [Environment]::GetEnvironmentVariable("PATH", "Process") -split ";"
$env:PATH = ($machinePath + $userPath + $processPath | Select-Object -Unique) -join ";"
Write-EventLogWrapper -message "Updated PATH environment variable`r`n`r`nNew value: $($env:PATH -replace ';', "`r`n")`r`n`r`nOld value: $($oldPath -replace ';', "`r`n")"
}
# Install Chocolatey itself:
Invoke-WebRequest https://chocolatey.org/install.ps1 -UseBasicParsing | Invoke-Expression
# NOTE: Chocolatey changes the system %PATH%, so we have to get the latest update here:
Update-EnvironmentPath
# Configure Chocolatey to not require confirmation when installing packages:
choco.exe feature enable --name=allowGlobalConfirmation --yes
# Install the package we care about
choco.exe install git
# Installing Git also changes the system %PATH%, so we have to update it again:
Update-EnvironmentPath

Related

VCPKG package installation fails on wrong path with semicolon

I'm new to MSYS2, VCPKG and CMAKE. I want to build package MSDFGEN via MSYS2/UCRT64 and VCPKG on Windows. What I did so far:
Installed Visual Studio Community Edition + Installed MSYS2 + started UCRT64 console
Added paths C:\msys64\ucrt64\bin;C:\msys64\usr\bin;
Then in UCRT64 console:
pacman -Syu
pacman -Su
pacman -S --needed base-devel mingw-w64-ucrt-x86_64-toolchain git cmake
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.bat -disableMetrics
./vcpkg.exe integrate install
./vcpkg.exe install msdfgen
Result:
Computing installation plan...
The following packages will be built and installed:
* brotli[core]:x86-windows -> 1.0.9#4
* bzip2[core,tool]:x86-windows -> 1.0.8#3
* freetype[brotli,bzip2,core,png,zlib]:x86-windows -> 2.12.1#3
* libpng[core]:x86-windows -> 1.6.39
msdfgen[core]:x86-windows -> 1.9.2
* vcpkg-cmake[core]:x64-windows -> 2022-10-30
* vcpkg-cmake-config[core]:x64-windows -> 2022-02-06#1
* zlib[core]:x86-windows -> 1.2.13
Additional packages (*) will be modified to complete this operation.
Detecting compiler hash for triplet x64-windows...
error: while detecting compiler information:
The log file content at "C:\msys64\home\myname\vcpkg\buildtrees\detect_compiler\stdout-x64-windows.log" is:
CMake Error at C:/msys64/home/myname/vcpkg/scripts/ports.cmake:110 (message):
Cannot find port:
Directory does not exist: C;/msys64/home/myname/vcpkg/scripts/detect_compiler
error: vcpkg was unable to detect the active compiler's information. See above for the CMake failure output.
Directory detect_compiler exists, but notice that path includes semicolon. How do I fix this?
Most likely the issue is with some incorrectly set environment variable in your system (or any other CMake variable) to debug this issue I would start by figuring out if you can find the variable responsible (maybe it's the PATH) variable. To debug this, try running this command in powershell:
dir env: | out-string -stream | Select-String -Pattern "C;/msys64"
Or just:
dir env: | out-string -stream | Select-String -Pattern "C;"
After you figure out which variable it is, then you can set it properly.
EDIT: I've noticed that you aren't using the correct triplets (I've mentioned it in the comments, but here it may have better formatting):
Try exporting these variables, so that you download the correct triplets when using mingw64:
export VCPKG_DEFAULT_TRIPLET=x64-mingw-dynamic
export VCPKG_DEFAULT_HOST_TRIPLET=x64-mingw-dynamic
As is mentioned here in this link
EDIT2: It may seem that the UCRT64 environment is not supported by VCPKG, hence I am not sure if the MinGW triplets will solve the issue (but you may try).

R-INLA installation fails on R 4.1.1

I need to install R-INLA on R 4.1.1 (Windows 10). I cannot update the R version due to compatibility issues of the newer R installations with other tools I that use. I tried the line:
remotes::install_version("INLA", version="22.05.03",repos=c(getOption("repos"),INLA="https://inla.r-inla-download.org/R/testing"), dep=TRUE)
As recommended on the INLA website for R 4.1. I get this message in return:
* installing *binary* package 'INLA' ...
cp: unknown option -- )
Try '/usr/bin/cp --help' for more information.
ERROR: installing binary package failed
* removing 'C:/Program Files/R/R-4.1.1/library/INLA'
I have rtools40 installed and added to my path. I have installed the two suggested packages graph and Rgraphviz as recommended.
I have also tried:
devtools::install_github(repo = "https://github.com/hrue/r-inla", ref = "stable", subdir = "rinla", build = FALSE)
But no luck there either.
If I type where cp in the RStudio terminal, I get:
$ where cp
C:\Program Files\Git\usr\bin\cp.exe
C:\rtools40\usr\bin\cp.exe
But I am not sure if this has anything to do with R not finding cp.
Anyone has any advice?
I was having the same problem, and solved it for my Windows 10 machine:
Download the INLA_22.05.03.zip file at https://inla.r-inla-download.org/R/stable/bin/windows/contrib/4.1/
In RStudio, under the Tools menu, select Install Packages, and Install from: Package Archive File. Tell RStudio where the .zip file is located on your local machine. From there it installed fine for me.

Why is 7-Zip failing during this Chocolatey installation on Windows 10?

I am trying to install Chocolatey
https://chocolatey.org/install
and using the command:
#"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
It is showing error:
Unable to unzip package using 7zip. Perhaps try setting $env:chocolateyUseWindowsCompression = 'true' and call install
again. Error: 7-Zip encountered a fatal error while extracting the files
At line:221 char:9
+ 2 { throw "$errorMessage 7-Zip encountered a fatal error while ex ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (Unable to unzip...cting the files:String) [], RuntimeException
+ FullyQualifiedErrorId : Unable to unzip package using 7zip. Perhaps try setting $env:chocolateyUseWindowsCompres
sion = 'true' and call install again. Error: 7-Zip encountered a fatal error while extracting the files
I have 7zip installed.
I encounter the same issue.
Running window cmd as administrator may be a solution for some but in my case i had to update my window system environment variable,
I just added this to exiting value on
path: $env:chocolateyUseWindowsCompression = 'true'
and all works just fine.
I had the same error when I was trying to install chocolatey on multiple servers which was finally getting blocked at chocolatey server, which is a chocolatey feature.
https://chocolatey.org/docs/community-packages-disclaimer#rate-limiting
Hence the downloaded file is null and cannot be unzipped. The block is lifted an hour later. After rate limit is lifted, the errors disappears until you trigger it again.
Rate limiting also applies to other packages. When limit is hit while downloading a package other than chocolatey itself, you will get an error code 429.
https://chocolatey.org/docs/troubleshooting#im-getting-a-429-too-many-requests-issue-when-attempting-to-use-the-community-package-repository
First answer: Running window cmd as administrator may be a solution for some but in my case i had to update my window system environment variable, I just added this to exiting value on path: $env:chocolateyUseWindowsCompression = 'true' and all works just fine.
may not work immediately and you still receive "Unable to unzip package using 7zip." error.
Try again after restarting your machine. In my case command works after restarting.
Thx
karam
After a few months, i ran the same command from cmd with Administrative Privilege and it worked. The main point was running
cmd.exe As an Administrator.

Unable to find module providers

I'm having an issue with PowerShell. It's almost like it's not installed all the way; which is weird since it's Windows 10 and it ships with it.
With no lock, I've tried replacing the following directories with a fresh copy from another Windows 10 machine that is working:
C:\Users\UserName\AppData\Local\PackageManagement
C:\Program Files\WindowsPowerShell
C:\Program Files (x86)\WindowsPowerShell
C:\Windows\System32\WindowsPowerShell
I also tried SFC /scannow, but it found no issues. I've searched for hours and haven't been able to find anyone with the exact same issue. Does anyone have any ideas?
System Information:
PS C:\WINDOWS\system32> [environment]::OSVersion.Version
Major Minor Build Revision
----- ----- ----- --------
10 0 10586 0
PS C:\WINDOWS\system32> $PSVersionTable.PSVersion
Major Minor Build Revision
----- ----- ----- --------
5 0 10586 122
Errors:
PS C:\WINDOWS\system32> Get-PSRepository
PackageManagement\Get-PackageSource : Unable to find module providers (PowerShellGet).
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:3544 char:31
+ ... ckageSources = PackageManagement\Get-PackageSource #PSBoundParameters
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument:(Microsoft.Power...etPackageSource:GetPackageSource) [Get-PackageSource
], Exception
+ FullyQualifiedErrorId : UnknownProviders,Microsoft.PowerShell.PackageManagement.Cmdlets.GetPackageSource
PS C:\WINDOWS\system32> Get-PackageProvider -Name PSModule -ForceBootstrap
Get-PackageProvider : Unable to find package provider 'PSModule'. It may not be imported yet. Try 'Get-PackageProvider
-ListAvailable'.
At line:1 char:1
+ Get-PackageProvider -Name PSModule -ForceBootstrap
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Microsoft.Power...PackageProvider:GetPackageProvider) [Get-PackageProvi
der], Exception
+ FullyQualifiedErrorId : UnknownProviderFromActivatedList,Microsoft.PowerShell.PackageManagement.Cmdlets.GetPacka
geProvider
The below returns nothing:
PS C:\WINDOWS\system32> Get-PackageProvider -ListAvailable
PS C:\WINDOWS\system32>
If your end goal is to install packages from Chocolatey or something similar with PowerShell you would want to perform the following.
To import the Module you would execute the following:
Import-Module PackageManagement
To install the package providers you would execute the following:
Install-PackageProvider -Name Chocolatey -Force
To find a package within the package provider Chocolatey you would execute the following (you could use wildcard for name to get all packages available):
Find-Package -Name SomePackageNameHere -ProviderName Chocolatey
Lastly, to install a package from Chocolatey you would execute the following:
Install-Package -Name SomePackageNameHere -ProviderName Chocolatey -Force
I hope this helps!
Looks like I solved the issue. I installed Chocolatey by using the CMD.exe method.
I ran CMD.exe as an administrator and ran the following command:
#powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin
Now I have a PS Repository:
PS C:\WINDOWS\system32> Get-PSRepository
Name PackageManagementProvider InstallationPolicy SourceLocation
---- ------------------------- ------------------ --------------
PSGallery NuGet Untrusted https://www.powershellgallery.com/api/v2/
I'm guessing something during the install of Chocolatey, repaired whatever was broken.

Set environment variables for current chef-client run

I'm trying to use chef to install OpenJDK, as well as downoad Eclipse and install a few plugins using p2 director on a Windows 2008 node. OpenJDK installs and I set my environment variables JAVA_HOME and add it to the path.
However, this change does not take affect until I close and re-open PowerShell. The chef-client run needs these in the current session to run the eclipse p2 director. Is there any way to do this so that I can run chef-client only once?
In my recipe for installing openJDK I included:
env "JAVA_HOME" do
value 'C:\\Program Files\\Zulu\\zulu-8'
end
env "path" do
delim ";"
value '%JAVA_HOME%\\bin'
action :modify
end
#For Command Prompt
execute "setPathCMD" do
command "set PATH=#{node['java']['path']}\\bin;%PATH%"
end
#For PowerShell
powershell_script "setPathPS" do
code <<-EOH
$env:Path="#{node['java']['path']}\\bin;$env:Path"
EOH
end
ENV['Path'] += ";C:\\Program Files\\Zulu\\zulu-8\\bin"
And in the recipe for installing the eclipse plugins I have:
if not node['eclipse']['plugins'].empty?
node['eclipse']['plugins'].each do |plugin_group|
repo, id = plugin_group.first
execute "eclipse plugin install" do
command "#{node['eclipse']['unzip_location']}/eclipse/eclipse.exe -application org.eclipse.equinox.p2.director -noSplash -repository #{repo} -installIUs #{id}"
action :run
end
end
end
Try using setx:
execute 'set java_home' do
command "setx -m JAVA_HOME \"C:\\Program Files\\Zulu\\zulu-8\""
only_if { ENV['JAVA_HOME'] != 'C:\\Program Files\\Zulu\\zulu-8' }
end
# Set JAVA_HOME for this process
ENV['JAVA_HOME'] = 'C:\\Program Files\\Zulu\\zulu-8'
# do something similar for path...
Adapted from the visualstudio cookbook for enabling NuGet package restore:
https://github.com/daptiv/visualstudio/blob/master/recipes/nuget.rb
Put on your client.rb or solo.rb:
ENV['VAR'] = 'value'

Resources