' ファイルシステムオブジェクトを取得する。 Set fso = WScript.CreateObject("Scripting.FileSystemObject") ' 日付の生成 yDate = year(now()) moDate = Right(00 & Month(now()), 2) daDate = Right(00 & Day(now()), 2) hoDate = Right(00 & Hour(now()), 2) miDate = Right(00 & Minute(now()), 2)
if miDate = 00 then
hoDate = Right(00 & Hour(now()), 2) -1 miDate = "59"
else
miDate = Right(00 & Minute(now()), 2) -1
end if
strDate = yDate & moDate & daDate & hoDate & miDate
' ' ディレクトリを指定 chkDir = "C:\Documents and Settings\PT4\デスクトップ\test\"
' エラーメッセージ errMsg = "エラーが発生しています!"
' ファイル名を指定 errLog = chkDir & strDate
' 音声ファイルの指定 strSoundFile = "C:\WINDOWS\Media\Windows XP Ringin.wav"
' ファイルの存在を確認する If FileExists( errLog & "*" ) Then
set objectShell = CreateObject("wscript.Shell")
strCommand = "sndrec32 /play /close " & chr(34) & strSoundFile & chr(34)
objectShell.Run strCommand, 0, True
errNow = Now()
WScript.Echo errMsg,"(",errNow,")"
End If
' オブジェクトの開放 Set fso = Nothing
Function FileExists(Spec) Dim fso Dim ParentFolderName Set fso=CreateObject("Scripting.FileSystemObject") ParentFolderName=fso.GetParentFolderName(Spec) If ParentFolderName="" Then ParentFolderName="." On Error Resume Next fso.CopyFile Spec,ParentFolderName 'fso.MoveFile Spec,ParentFolderName FileExists=Err.Number<>53 End Function