0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

eclipseのupdate siteをダウンロードするバッチ

0
Posted at

うちの社内では協力会社の方がインターネットを使うことができないので
eclipseのプラグインをインストールしたくてもupdate siteに接続することができない。

そこで、update siteを社内で配布できるarchiveとしてダウンロードするバッチを作ってみた。

'**********初期設定***********
'eclipseのインストールディレクトリ(eclipse.exeの場所)
const eclipseDir = "C:\eclipse" 
'*****************************

'変数宣言
dim updateSite
dim cdir
dim tempDir
dim ZipFile
dim objWshShell
dim fso


set objWshShell = WScript.CreateObject("WScript.Shell")
set fso = CreateObject("Scripting.FileSystemObject")

'入力プロンプト
updateSite = InputBox("updateSiteのURLを入力してください。")

'カレントディレクトリに作成する
cdir = objWshShell.CurrentDirectory
tempDir = cdir & "\temp"
ZipFile = cdir & "\updateSite.zip"

'一時フォルダ存在チェック
If fso.FolderExists(tempDir) = True Then
    strMessage = "tempフォルダが既に存在するため作業を中断します。"
Else
    fso.CreateFolder(tempDir)
End If

'updatesiteのダウンロードを実行。非同期なので終わるまでループで待つ
objWshShell.Run eclipseDir & "\eclipse.exe -nosplash -verbose -application org.eclipse.equinox.p2.metadata.repository.mirrorApplication -source " & updateSite & " -destination " & tempDir, 0, False 
objWshShell.Run eclipseDir & "\eclipse.exe -nosplash -verbose -application org.eclipse.equinox.p2.artifact.repository.mirrorApplication -source " & updateSite & " -destination " & tempDir, 0, False 

dim fsize

'10秒間サイズが変わらなければダウンロード完了と見る
Do
    fsize = fso.GetFolder(tempDir).Size
    'ダウンロード開始に時間がかかるときがあるのでサイズ0のときは終わらないようにする
    if fsize = 0 then
    	fsize = -1
    end if
    wScript.Sleep 10000
Loop Until fso.GetFolder(tempDir).Size = fsize

'ダウンロードが終わったらzipに固める
fso.CreateTextFile(ZipFile, True).Write "PK" & Chr(5) & Chr(6) & String(18, vbNullChar)
Set objShell = CreateObject("Shell.Application")
Set source = objShell.NameSpace(tempDir).Items
objShell.NameSpace(ZipFile).CopyHere(source)

'10秒間サイズが変わらなければ圧縮完了とみなす
Do
    fsize = fso.GetFile(ZipFile).Size
    wScript.Sleep 10000
Loop Until fso.GetFile(ZipFile).Size = fsize

'一時フォルダは削除
fso.DeleteFolder tempDir
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?