我需要编写一个启动批处理脚本,以便在Windows Server 2016计算机上下载并安装最新版本的Mozilla Firefox。非常感谢您的帮助。
答案 0 :(得分:0)
尝试使用 Sachadee 编写的批处理脚本。
::FIREFOX TOTAL SILENT FTP-INSTALL
::BY SachaDee
::08-2013
::www.batch.xoo.it
@echo off
setlocal ENABLEDELAYEDEXPANSION
:start
cls&color 18
md "%temp%\fire_install"
pushd "%temp%\fire_install"
@echo off
(echo anonymous
echo.
echo cd pub/mozilla.org/firefox/releases/latest/win32/fr
echo mget *.exe
echo bye)>firefox.ftp
ftp -s:firefox.ftp -i ftp.mozilla.org
if exist *.exe (echo firefox telecharger avec succes
for %%a in (*.exe) do (echo "%%a" | find /i "stub"
set $en_cours=%%a
if !errorlevel!==0 (del "!$en_cours!"
goto:install)))
:demande
set /p $rep=Le Download a ‚chou‚ recommencer ? [O/N] :
if /i %$rep%==o goto:start
if /i %$rep%==n goto:end
cls&Echo La R‚ponse doit etre O ou N
goto:demande
:install
for %%a in (*.exe) do (CALL "%%a" -ms)
echo.&echo INSTALLATION TERMINEE
pause
:end
del /q "%temp%\fire_install"\*.*
endlocal
popd
答案 1 :(得分:0)
不是最好的代码,但它应该可以正常工作,因为它听起来像你需要的。我很快就把它放在了一起。由于它是.exe文件,因此可能存在一个问题,即它是否要保留或丢弃该文件。我仍然会放入没有这个问题的代码。将"dir=C:\Users\USERNAME\Downloads"
更改为您下载的目录,I.E。 C:\Users\Jim\Downloads
。
@echo off
title Download Firefox Newest Version
color 07
rem ---- Easily change site download and directory ----
set "dir=C:\Users\USERNAME\Downloads"
set "download=https://www.mozilla.org/en-US/firefox/new/?scene=2"
echo Opening Firefox Download... (%download%)
rem ---- Checks if file exists and if it does, start it ----
:openloop
pause
if exist %dir% (
rem Firefox Exists
cd %dir%
echo Starting Firefox Installer.exe
start Firefox Installer.exe
exit
) else (
rem Firefox doesn't exist
goto openloop
)
echo Whoops, something went wrong
pause >nul
exit
答案 2 :(得分:0)
您可以使用第三方(例如 wget 或 curl
)查看Readme.txt of Mozilla Firefox以下载最新版本的FirefoxPlease use download.mozilla.org to retrieve the latest Firefox release.
For example, if you wish to download the US English installer for Windows (32bit)
the url is
https://download.mozilla.org/?product=firefox-latest&os=win&lang=en-US
This could be pasted into the location bar of a browser, or used with curl or wget, e.g.
wget -O FirefoxSetup.exe "https://download.mozilla.org/?product=firefox-latest&os=win&lang=en-US"
For other operating systems replace 'os=win' with:
Windows 64bit os=win64
OS X os=osx
Linux x86_64 os=linux64
Linux i686 os=linux
For other languages replace 'lang=en-US' with:
Acholi lang=ach
Afrikaans lang=af
Albanian lang=sq
Arabic lang=ar
Aragonese lang=an
Armenian lang=hy-AM
Assamese lang=as
Asturian lang=ast
Azerbaijani lang=az
Basque lang=eu
Belarusian lang=be
Bengali (Bangladesh) lang=bn-BD
Bengali (India) lang=bn-IN
Bosnian lang=bs
Breton lang=br
Bulgarian lang=bg
Catalan lang=ca
Chinese (Simplified) lang=zh-CN
Chinese (Traditional) lang=zh-TW
Croatian lang=hr
Czech lang=cs
Danish lang=da
Dutch lang=nl
English (British) lang=en-GB
English (South African) lang=en-ZA
Esperanto lang=eo
Estonian lang=et
Finnish lang=fi
French lang=fr
Frisian lang=fy-NL
Fulah lang=ff
Gaelic (Scotland) lang=gd
Galician lang=gl
German lang=de
Greek lang=el
Gujarati (India) lang=gu-IN
Hebrew lang=he
Hindi (India) lang=hi-IN
Hungarian lang=hu
Icelandic lang=is
Indonesian lang=id
Irish lang=ga-IE
Italian lang=it
Kannada lang=kn
Kazakh lang=kk
Khmer lang=km
Korean lang=ko
Latvian lang=lv
Ligurian lang=lij
Lithuanian lang=lt
Lower Sorbian lang=dsb
Macedonian lang=mk
Maithili lang=mai
Malay lang=ms
Malayalam lang=ml
Marathi lang=mr
Norwegian (Bokmål) lang=nb-NO
Norwegian (Nynorsk) lang=nn-NO
Oriya lang=or
Persian lang=fa
Polish lang=pl
Portuguese (Brazilian) lang=pt-BR
Portuguese (Portugal) lang=pt-PT
Punjabi (India) lang=pa-IN
Romanian lang=ro
Romansh lang=rm
Russian lang=ru
Serbian lang=sr
Sinhala lang=si
Slovak lang=sk
Slovenian lang=sl
Songhai lang=son
Spanish (Argentina) lang=es-AR
Spanish (Chile) lang=es-CL
Spanish (Mexico) lang=es-MX
Spanish (Spain) lang=es-ES
Swedish lang=sv-SE
Tamil lang=ta
Telugu lang=te
Thai lang=th
Turkish lang=tr
Ukrainian lang=uk
Upper Sorbian lang=hsb
Uzbek lang=uz
Vietnamese lang=vi
Welsh lang=cy
Xhosa lang=xh
这是另一个使用powershell下载具有管理员权限的firefox设置的批处理文件:
@echo off
Mode 80,5 & color 0A
Title Downloading Firefox Setup from web using powershell and batch by Hackoo 2018
:::::::::::::::::::::::::::::::::::::::::
:: Automatically check & get admin rights
:::::::::::::::::::::::::::::::::::::::::
REM --> Check for permissions
Reg query "HKU\S-1-5-19\Environment" >nul 2>&1
REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
Echo(
ECHO **************************************
ECHO Running Admin shell... Please wait...
ECHO **************************************
goto UACPrompt
) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
set params = %*:"=""
echo UAC.ShellExecute "cmd.exe", "/c ""%~s0"" %params%", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
del "%temp%\getadmin.vbs"
exit /B
:gotAdmin
::::::::::::::::::::::::::::
::START
::::::::::::::::::::::::::::
Mode 110,3 & color 0A
Set "URL=http://download.cdn.mozilla.net/pub/firefox/releases/57.0.4/win32/en-US/Firefox Setup 57.0.4.exe"
Set "FileLocation=%userprofile%\Desktop\Firefox Setup 57.0.4.exe"
echo(
echo Please wait a while ... Downloading file to "%FileLocation%"
Call :BalloonTip 'information' 10 '"Downloading Firefox Setup.exe"' "'Please wait... Downloading Firefox Setup.exe....'" 'info' 4
Call :Download "%url%" "%FileLocation%"
If "%errorlevel%" EQU "1" (
Color 0C
echo There is an error occured ! & Timeout /T 4 /Nobreak>nul & exit
) else (
If exist "%FileLocation%" Start "" "%FileLocation%"
)
Exit
::*********************************************************************************
:Download <url> <File>
Powershell.exe -command "(New-Object System.Net.WebClient).DownloadFile('%1','%2')"
exit /b
::*********************************************************************************
:BalloonTip $notifyicon $time $title $text $icon $Timeout
PowerShell ^
[reflection.assembly]::loadwithpartialname('System.Windows.Forms') ^| Out-Null; ^
[reflection.assembly]::loadwithpartialname('System.Drawing') ^| Out-Null; ^
$notify = new-object system.windows.forms.notifyicon; ^
$notify.icon = [System.Drawing.SystemIcons]::%1; ^
$notify.visible = $true; ^
$notify.showballoontip(%2,%3,%4,%5); ^
Start-Sleep -s %6; ^
$notify.Dispose()
%End PowerShell%
exit /B
::********************************************************************************