[英]How to write a batch file to download and install Firefox on Windows machine?
我需要編寫啟動批處理腳本以在Windows Server 2016計算機上下載並安裝最新版本的Mozilla Firefox。 非常感謝您的幫助。
試試這個由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
不是最好的代碼,但是對於您所需要的聽起來應該可以。 我只是很快把它放在一起。 由於它是一個.exe文件,因此它可能會詢問您要保留還是丟棄該文件的位置。 我仍然會放入沒有此問題的代碼。 將"dir=C:\\Users\\USERNAME\\Downloads"
更改為"dir=C:\\Users\\USERNAME\\Downloads"
的目錄,即IE 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
您可以查看Mozilla Firefox的Readme.txt,以使用諸如wget或curl的第三方下載最新版本的Firefox。
Please 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
::********************************************************************************
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.