Skip to content

Instantly share code, notes, and snippets.

Avatar

bouzuya bouzuya

View GitHub Profile
View rotate-backup.wsf
<?xml version="1.0" standalone="yes"?>
<package>
<job id="RotateBackup">
<?job error="false" debug="true"?>
<runtime>
<description>
バックアップをローテーションする。
</description>
<named
name="srcfile"
View rotate-backup.vbs
Option Explicit
Sub Main()
Dim srcfile, dstdir
If Not WScript.Arguments.Named.Exists("srcfile") Then
WScript.Echo("srcfile is required.")
WScript.Quit(1)
Exit Sub
End If
srcfile = WScript.Arguments.Named.Item("srcfile")
View rotate-backup.vbs
Option Explicit
Private Function ValidateArguments()
If Not WScript.Arguments.Named.Exists("srcfile") Then
WScript.Echo("srcfile is required.")
ValidateArguments = False
Exit Function
End If
If Not WScript.Arguments.Named.Exists("dstdir") Then
WScript.Echo("dstdir is required.")
View import.vbs
Public Sub Import(ByVal strFileName)
Const ForReading = 1
Dim objFso, objFile
Set objFso = WScript.CreateObject("Scripting.FileSystemObject")
Set objFile = objFso.OpenTextFile(strFileName, ForReading, False)
ExecuteGlobal objFile.ReadAll()
objFile.Close()
End Sub
Call Import("string.vbs")
View rotate-backup.vbs
Option Explicit
Public Sub Import(ByVal strFileName)
Const ForReading = 1
Dim objFso, objFile
Set objFso = WScript.CreateObject("Scripting.FileSystemObject")
Set objFile = objFso.OpenTextFile(strFileName, ForReading, False)
ExecuteGlobal objFile.ReadAll()
objFile.Close()
End Sub
View scripts.wsf
<?xml version="1.0" standalone="yes"?>
<package>
<job id="RotateBackup">
<?job error="false" debug="true"?>
<runtime>
<description>
バックアップをローテーションする。
</description>
<named
name="srcfile"
View rotate-backup.vbs
Option Explicit
Private Sub Copy(ByVal strSrc, ByVal strDst)
Dim objFso
Set objFso = WScript.CreateObject("Scripting.FileSystemObject")
If objFso.FileExists(strSrc) Then
Call objFso.CopyFile(strSrc, strDst)
Else
' do nothing
End If
View rotate-backup.vbs
Option Explicit
Private Function Main()
If Not ValidateArguments() Then
Main = 1
Exit Function
End If
Dim strSrcFile, strDstDir
strSrcFile = WScript.Arguments.Named.Item("srcfile")
strDstDir = WScript.Arguments.Named.Item("dstdir")
View rotate-backup-fso.vbs
Option Explicit
Public Function PathCombine(ByVal strPath1, ByVal strPath2)
Dim objFso
Set objFso = WScript.CreateObject("Scripting.FileSystemObject")
PathCombine = objFso.BuildPath(strPath1, strPath2)
End Function
Public Sub Copy(ByVal strSrcPath, ByVal strDstPath)
Dim objFso
View capture-screen.vbs
Option Explicit
Const INTERVAL_SEC = 10
Const WINSHOT_PATH = "C:\Users\user\Documents\ws153a\winshot.exe"
Const WINSHOT_OPTS = "-J -D -X"
Const FFMPEG_PATH = "C:\Users\user\Documents\ffmpeg\bin\ffmpeg.exe"
Const CAPTURE_DIR = "C:\Users\user\Pictures\winshot\"
Dim objShell, objFso
Set objShell = WScript.CreateObject("WScript.Shell")