[VBScript][Powershell 2.0]Windows 7 32 bit Chrome Firefox Acrobat DownLoad And Silent Install
レンタルPCはWin7やVISTAはありうる
そういうPCしかレンタルしないところでは初期設定をする必要があります。
しかし、
- Powershellが2.0
- 管理者権限は起動する
- ただし再起動すると元に戻る
という縛りがあります。こうした場合、少なくともブラウザを入れなければなりません。
Windows 7 32 bitの初期はPowershellのVersionが2.0だと使えない命令がある
unblock-file
は使えない
unblock-file
は使えないDescription
The Unblock-File cmdlet lets you open files that were downloaded from the Internet. It unblocks Windows PowerShell script files that were downloaded from the Internet so you can run them, even when the Windows PowerShell execution policy is RemoteSigned. By default, these files are blocked to protect the computer from untrusted files.
Before using the Unblock-File cmdlet, review the file and its source and verify that it is safe to open.
Internally, the Unblock-File cmdlet removes the Zone.Identifier alternate data stream, which has a value of "3" to indicate that it was downloaded from the Internet.
For more information about Windows PowerShell execution policies, see about_Execution_Policies (http://go.microsoft.com/fwlink/?LinkID=135170).
This cmdlet is introduced in Windows PowerShell 3.0.Notes
The Unblock-File cmdlet works only in file system drives.
Unblock-File performs the same operation as the Unblock button on the Properties dialog box in File Explorer.
If you use the Unblock-File cmdlet on a file that is not blocked, the command has no effect on the unblocked file and the cmdlet does not generate errors.
Chrome
ワンライナーで完了する
DeskTopにダウンロードして、サイレントインストールを行う。ただし後半のデスクトップがユーザー名がわからないと動かない。しかしよく考えると $ofolderで crhome.exeまで入っているので、これをStart-Processで動かすようにした。その前に、WhileでWaitをつけた。
Cls;$ofolder = join-path ($env:userprofile + '\Desktop') 'Chorme.exe'; (new-object System.Net.WebClient).DownloadFile('http://dl.google.com/chrome/install/375.126/chrome_installer.exe', $ofolder); while( -not (test-path $ofolder)){Start-Sleep 500} ; if(test-path $ofolder){Start-process -filepath $ofolder ' /silent /install'};
以前のB版
Cls;$ofolder = join-path ($env:userprofile + '\Desktop') 'Chorme.exe'; (new-object System.Net.WebClient).DownloadFile('http://dl.google.com/chrome/install/375.126/chrome_installer.exe', $ofolder); 'C:\Users\name\Desktop\chorme.exe /silent /install';
こんどこちらを試してみます 未テストのBeta Versionです。
powershell
Cls;$ofolder = join-path ($env:USERPROFILE + '\Desktop') 'Chorme.exe'; (new-object System.Net.WebClient).DownloadFile('http://dl.google.com/chrome/install/375.126/chrome_installer.exe', $ofolder);$env:USERPROFILE'\desktop\chorme.exe /silent /install';
さらに起動にはいろいろなオプションがあります
Firefox
DownloadサイトとFile名の確定
ダウンロードサイトを探し、ファイル名を決めてScriptを組みます。
ここではWindows 7 32bitを前提にしています
URLと実行形式ファイルを探すその1
https://download-installer.cdn.mozilla.net/pub/firefox/releases/
ここでVersionをあわせる
Windows 7 の現在の32bitバージョンは65.0
次にwin32
次に言語、日本は ja
たとえ多少古くなっても、更新を繰り返すことで最新バージョンになる。
URLと実行形式ファイルを探すその2
Pulswayは
https://www.mozila.org/en-US/firefox/all/
としている。mozillaは日本語は ja
Microsoftは ja-jp
なので短い
すると、
https://www.mozilla.org/ja/firefox/all/
これは通るのか。
結果はYes!
https://download.mozilla.org/?product=firefox-latest-ssl&os=win64&lang=ja
https://download.mozilla.org/?product=firefox-latest-ssl&os=win&lang=ja
この方法は、Batファイルを組んでいる、ここでも同じ手法で探されている。
Project Group >> HOME >> Tips >> Microsoft Windows >> コマンド プロンプト >> Mozilla Firefox をサイレントインストールする方法
URLがわかったらPowershell VBScriptの書き換え
VBScriptでWebからファイルダウンロード - しおそると 4月 27, 2008
Install Firefox Powershell - pulseway By kavaa, February 14, 2017 in PowerShell
この2つを組み合わせていく
'HTTP Request作成等の解説は Home » Access » HTMLソースを取得するならXMLHTTPオブジェクトを使う方法がおすすめ!HTMLソースを取得するならXMLHTTPオブジェクトを使う方法がおすすめ! - infith
によって付加。
Powershell 2.0 Later Win32 Ja FireFox version(65.0) DownLoad And Scilent Install
一方Powershellは3.0以降はワンライナーにしうるが、Windows7 32 bitのPowershell 2.0では Invoke-WebRequest
が使えない。
そこで、ワンライナーはやめて、Whileで待機することにした。
DownLoad とサイレンとインストールを同時に行う。
Powershell_Iseを管理者権限で起動すること。
環境変数でDownloadsにつなぐ
Userprofile
`$env:USERPROFILE'
Downloadフォルダには環境変数で+でつなぐ
変数は文字型を強制
[string]$strFolder = $env:USERPROFILE + '\Downloads'
# Powershell 2.0 available ( Exclude Invoke-WebRequest Command)
# Powershell(またはPowershell_ISE)管理者権限で起動してください You needs Powershell/Powershell_ISE runas adminstrator
# ファイルのフォルダはダウンロードが前提です This Script Run on C:\users\name\Downloads
# この中で設定しているURLとファイル名には、この記事を書いたときの最新のWindows 7 32bit 日本語版を設定しています。for Windows 7 32 bit Japanese version
ClS;
#Download Folderで作業します
[string]$strFolder = $env:USERPROFILE + '\Downloads';
$FFWin32_65_0JPN = "https://download-installer.cdn.mozilla.net/pub/firefox/releases/65.0/win32/ia/Firefox%20Setup%2065.0.exe"
$FFWin32_65_0JPNExe = "Firefox Setup 65.0.exe"
#Current Directory Change
chdir $strFolder;
$FFWin32_65_0JPNExe ="Firefox Setup 65.0.exe";
$executefile = Join-Path $strFolder $FFWin32_65_0JPNExe;
$WebClient = New-Object System.Net.WebClient ; $WebClient.DownloadFile($FFWin32_65_0JPN, $executefile);
while( -not (test-path $executefile)){Start-Sleep 500} ;
If(Test-Path $executefile){Start-Process -FilePath $executefile " -ms"};
実はWindows XP (SP3)も可能
Chrome(たしか無理)
Firefox(確認中)
Acrobat
DownloadFolderがないのでDesktopにする。
Acrobat日本語の最終版は11.0.8
ftp://ftp.adobe.com/pub/adobe/reader/win/11.x/11.0.08/ja_JP/AdbeRdr11008_ja_JP.exe
完成か
注意書き
- Chromeを使います。このため事前にChromeをサイレントインストールしてください
- ファイルの置き場所はDesktopに設定しています。
- まず動かす前にFtpのURLとダウンロードファイルをチェックしなければなりません。
- 現在のAcrobatDC版
ftp://ftp.adobe.com/pub/adobe/reader/win/AcrobatDC/1901020098/AcroRdrDC1901020098_ja_JP.exe
現在のAcrobat 11版
ftp://ftp.adobe.com/pub/adobe/reader/win/11.x/11.0.10/ja_JP/AdbeRdr11010_ja_JP.exe
なおAcrobat 11のサポートは2017年に終了している `
未完成
'Chorme.exe'; (new-object System.Net.WebClient).DownloadFile('ftp://ftp.adobe.com/pub/adobe/reader/win/11.x/11.0.08/ja_JP/AdbeRdr11008_ja_JP.exe ', $ofolder);$env:USERPROFILE'\desktop\AdbeRdr11008_ja_JP.exe /sPB /rs /rps /l';
Firefox VBScript batが動かないのでダウンロードまで版
MSXML2とADODB.Streamの組み合わせ
Proxyがある場合はこれでは動きません。
'=====================================================================
' スクリプトと同じディレクトリ上にファイルを保存します。今回は必ず ダウンロードフォルダです。
' Default Folder C:\users\name\Downloads
' Windows 7 Later
' USING MSXML2.ServerXMLHTTP
' if you need proxy for web browsing,use Proxycfg.exe
' see also:
' http://support.microsoft.com/kb/290761
' http://support.microsoft.com/kb/309436
'=====================================================================
'# Download the installer
Const adTypeBinary = 1 'StremaType Enum
'PulswayのURLとファイル名を定数化する
Const FFWin32_63_0_0JPN ="https://download-installer.cdn.mozilla.net/pub/firefox/releases/63.0.3/win32/ja/Firefox%20Setup%2063.0.3.exe"
Const FFWin32_63_0_0JPNExe ="Firefox Setup 63.0.3.exe"
Const FFWin32_65_0JPN = "https://download-installer.cdn.mozilla.net/pub/firefox/releases/65.0/win32/ia/Firefox%20Setup%2065.0.exe"
Const FFWin32_65_0JPNExe ="Firefox Setup 65.0.exe"
Call getHTTPasync(FFWin32_65_0JPN) 'ここでURLが入る
Sub getHTTPasync(strURL)
on error resume next
Dim objweb
Dim arwork
Dim objADO
Dim ret,res
arwork = split(strURL,"/")
strFname = Replace(Wscript.ScriptFullName,Wscript.ScriptName,"") & arwork(Ubound(arwork))
err.clear
Set objweb = CreateObject("MSXML2.ServerXMLHTTP.6.0")
'MSXML環境依存なるべく排除
if err.number <> 0 then
err.clear
Set objweb = CreateObject("MSXML2.ServerXMLHTTP")
end if
if err.number <> 0 then
err.clear
Set objweb = CreateObject("MSXML2.XMLHTTP")
end if
if err.number = 0 then
'objweb.Open "GET",strURL,False,"ユーザーID", "パスワード"
objweb.Open "GET", strURL, False
objweb.Send
res = objweb.responseBody
set objADO = CreateObject("ADODB.Stream")
objADO.Type = adTypeBinary 'BINARY
objADO.Open() 'ADODB.Steam を開き
objADO.Write(res) 'Binaryで書く
Wscript.Echo eplace(replace(strFname,"?","",1,-1),"=","",1,-1)
objADO.SaveToFile FFWin32_65_0JPNEXE ' SAVE CREATE OVERWRITE
objADO.Close
wscript.echo "接続ステータス : " & objweb.Status & " (" & objweb.statusText & ")" & _
vbCrLf & strFname & " に保存しました"
Set objADO = Nothing
Set objweb = Nothing
else ' err
wscript.echo "CreateObject失敗."
end if
End Sub
batファイルの作成
Firefox Setup 00.0.0.exeと同じDownloadフォルダに入れるbatファイル
firefox.bat
実行形式ファイル名はVersionとあわせる。
ただし元サイトと異なり、再起動はしません
@echo off
rem 実行ディレクトリを取得
set current_dir=%~dp0
rem Mozilla Firefox のインストールファイル名を設定
set fil=Firefox "Firefox Setup 65.0.exe"
rem Google Chrome をインストール 開始 -msがサイレントインストールを決定してるオプション
"%current_dir%\%fil%" -ms
rem 10秒後に再起動 無効化 レンタルなので初期設定に戻ってしまう
rem shutdown -r -t 10
exit
Author And Source
この問題について([VBScript][Powershell 2.0]Windows 7 32 bit Chrome Firefox Acrobat DownLoad And Silent Install), 我々は、より多くの情報をここで見つけました https://qiita.com/Q11Q/items/1c106161259012a8b62f著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .