Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@yaasita
Created October 12, 2013 18:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yaasita/6952987 to your computer and use it in GitHub Desktop.
Save yaasita/6952987 to your computer and use it in GitHub Desktop.
Option Explicit
'shellオブジェクト
Dim objWshShell
Set objWshShell = WScript.CreateObject("WScript.Shell")
'カレントディレクトリ変更
Dim objNetWork
Set objNetWork = WScript.CreateObject("WScript.Network")
Dim CYGHOME
CYGHOME="C:\cygwin\home\" & objNetWork.UserName
objWshShell.CurrentDirectory = CYGHOME
'ダウンロードパスの入力
Dim dir
dir = InputBox("ダウンロードするファイルのパスを入力してください")
If dir = "" Then
WScript.Echo "ファイルパスを入力してください"
WScript.Quit()
End If
'入力されたパスを/home/[USER]/targetdir.txtへ書き込み
Dim objFSO,objOutput
Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set objOutput = objFSO.OpenTextFile("targetdir.txt", ForWriting, True)
dir = Replace(dir,"\","/")
objOutput.WriteLine (dir)
objOutput.Close
Dim result
'dry run
Set result = objWshShell.Exec ("C:\cygwin\bin\bash.exe --login -c '~/rsync.pl -n'")
Do While result.Status = 0
WScript.Sleep 100
Loop
If result.ExitCode <> 0 Then
WScript.Echo "rsyncが異常終了しました" & vbCrLf & result.StdErr.ReadAll()
WScript.Quit()
End If
Dim yesno
yesno = MsgBox (result.StdOut.ReadAll() & vbCrLf & "続行しますか?", 4, "確認")
If yesno <> 6 Then
WScript.Quit()
End If
'run
Set result = objWshShell.Exec ("C:\cygwin\bin\bash.exe --login -c '~/rsync.pl'")
Do While result.Status = 0
WScript.Sleep 100
Loop
If result.ExitCode <> 0 Then
WScript.Echo "rsyncが異常終了しました" & vbCrLf & result.StdErr.ReadAll()
WScript.Quit()
End If
Set objWshShell = Nothing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment