从Windows命令行界面安装应用程序

时间:2020-02-23 14:45:30  来源:igfitidea点击:

如何在命令行界面上安装Windows上的程序/应用程序?
如何在Windows Server上安装Scoop?
在这篇文章中,将介绍如何使用Scoop命令行安装程序来安装我们在Linux中经常享受的最喜欢的开源应用程序。

使用Windows的Scoop命令行安装程序,我们不必担心Weird和Lend Wizard样式安装程序,权限弹出窗口和手动安装依赖项。
你所做的就是Fire命令,肮脏的工作是由Scoop处理的。

在Windows桌面/Windows Server上安装Scoop

使用PowerShell在Windows上安装Scoop。
以管理员用户身份登录并启动PowerShell。

PowerShell处于活动状态后,使用以下命令将SCOOP安装到其默认位置( C:\Users\<user>\scoop)

Set-ExecutionPolicy RemoteSigned -scope CurrentUser 
iex (new-object net.webclient).downloadstring('https://get.scoop.sh')

安装程序将下载,提取和安装scoop。

我们可以通过查看帮助页面来确认浏览器是否正常工作 scoop help

启用多连接下载

SCOPOP可以利用ARIA2使用多连接下载。
使用SCOOP安装ARIA2,然后将其用于后面的所有下载。

scoop install aria2

在Windows桌面/Windows Server上使用Scoop

这些是可供使用的scoop命令:

alias       Manage scoop aliases
bucket      Manage Scoop buckets
cache       Show or clear the download cache
checkup     Check for potential problems
cleanup     Cleanup apps by removing old versions
config      Get or set configuration values
create      Create a custom app manifest
depends     List dependencies for an app
export      Exports (an importable) list of installed apps
help        Show help for a command
home        Opens the app homepage
info        Display information about an app
install     Install apps
list        List installed apps
prefix      Returns the path to the specified app
reset       Reset an app to resolve conflicts
search      Search available apps
status      Show status and check for new app versions
uninstall   Uninstall an app
update      Update apps, or Scoop itself
virustotal  Look for app's hash on virustotal.com
which       Locate a shim/executable (similar to 'which' on Linux)

让我们考虑一些例子。

使用铲子安装应用程序

下面的例子将安装 aria2使用scoop下载Windows上的Manager。

PS C:\Users\Administrator> scoop install aria2
 Installing 'aria2' (1.34.0-1) [64bit]
 aria2-1.34.0-win-64bit-build1.zip (2.0 MB) [==================================================================] 100%
 Checking hash of aria2-1.34.0-win-64bit-build1.zip … ok.
 Extracting aria2-1.34.0-win-64bit-build1.zip … done.
 Linking ~\scoop\apps\aria2\current => ~\scoop\apps\aria2.34.0-1
 Creating shim for 'aria2c'.
 'aria2' (1.34.0-1) was installed successfully!

使用空格分隔它们来安装多个应用程序。

scoop install aria2 wget curl grep sed less touch vim sudo

已安装的应用程序位于用户的主目录上 ~/scoop/apps

搜索scoop包

使用搜索选项搜索可用包。
我最喜欢的命令是 which,它用于定位二进制可执行文件的路径。
我将使用scoop搜索这一点。

PS C:\Users\Administrator> scoop search which
 'main' bucket:
     busybox (2962-g9aae70405) --> includes 'which'
     gow (0.8.0) --> includes 'which.exe'
     which (2.20)

从输出中,我们可以确认哪种工具可用于安装。
使用 install命令得到它。

scoop install which

请参阅下面的屏幕截图。

用scoop卸载包

要卸载应用程序,请使用 scoop卸载命令。

PS C:\Users\Administrator> scoop uninstall sed
 Uninstalling 'sed' (4.2.1).
 Removing shim for 'sed'.
 Unlinking ~\scoop\apps\sed\current
 'sed' was uninstalled.

列出Scoop安装了应用程序

使用list命令获取所有已安装的应用程序的列表。

PS C:\Users\Administrator> scoop list
 Installed apps:
 7zip 19.00
   aria2 1.34.0-1
   cacert 2019-01-23
   curl 7.64.0_2
   grep 2.5.4
   less 550
   sudo 0.2016.07.25
   touch 0.2016.07.25
   vim 8.1.0999
   wget 1.20
   which 2.20

使用SCOOP安装的更新应用程序

update命令选项用于更新应用程序或者铲除本身。

首先安装git。

PS C:\Users\Administrator> scoop install git openssh 
# Then run:
[environment]::setenvironmentvariable('GIT_SSH', (resolve-path (scoop which ssh)), 'USER') scoop update

然后更新已安装的应用程序/scoop。

PS C:\Users\Administrator> scoop update
 Updating Scoop…
 Scoop was updated successfully!
PS C:\Users\Administrator> scoop update vim
 vim: 8.1.0999 (latest version)
 Latest versions for all apps are installed! For more information try 'scoop status'

设置应用程序的配置值

使用 config命令选项。
例如,将ARIA2重试到5次。

scoop config aria2-retry-wait 5

禁用ARIA2,使用

scoop config aria2-enabled false

删除应用程序旧版本

cleanup选项用于通过删除旧版本来清理应用程序。

PS C:\Users\Administrator> scoop cleanup vim
 vim is already clean