Option Explicit
'----------------------------------------
' ■■■戻り値(ret)の値一覧■■■
' 0:False値
' 1:True値
' ■■■第一引数の値一覧■■■
' 1:フォルダの存在チェック
' 2:ファイルの存在チェック
' 3:フォルダ、ファイルの存在チェック
' 4:編集可能ファイルかチェック
'----------------------------------------
Dim checkType, checkName, ret

'--- 引数の確認
If WScript.Arguments.Count > 1 Then
    checkType = WScript.Arguments.item(0)
    checkName = WScript.Arguments.item(1)
Else
'--- 指定がなければ処理終了
    WScript.Quit()
End IF

ret = 0
'--- 受け取った引数で条件分岐
Select Case checkType
	Case 1
		ret = folderCheck(checkName)
	Case 2
		ret = fileCheck(checkName)
	Case 3
		ret = dirCheck(checkName)
	Case 4
		ret = filePropertyCheck(checkName)
End Select

WScript.Quit ret

'■■■■■■■■■■■■■■■■■■
'■ 関数ここから                   ■
'■■■■■■■■■■■■■■■■■■
'------------------------------
' フォルダ存在チェックメソッド
'------------------------------
Function folderCheck(checkName)
	Dim objFSO, strFolder, ret
	ret = 0
	strFolder = checkName
	Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
	If Err.Number = 0 Then
	    If objFSO.FolderExists(strFolder) = True Then
	        ret = 1
	    End If
	End If
	Set objFSO = Nothing

	folderCheck = ret
End Function

'-------------------------------
' ファイル存在チェックメソッド
'-------------------------------
Function fileCheck(checkName)
	Dim objFSO, strFile, ret
	ret = 0
	strFile = checkName
	Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
	If Err.Number = 0 Then
	    If objFSO.FileExists(strFile) = True Then
	        ret = 1
	    End If
	End If
	Set objFSO = Nothing

	fileCheck = ret
End Function

'-----------------------------------------
' フォルダ&ファイル存在チェックメソッド
'-----------------------------------------
Function dirCheck(checkName)
	Dim objFSO, strDir, ret
	ret = 0
	strDir = checkName
	Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
	If Err.Number = 0 Then
		' フォルダの存在チェック
	    If objFSO.FolderExists(strDir) = True Then
	        ret = 1
	    End If
		' ファイルの存在チェック
	    If objFSO.FileExists(strDir) = True Then
	        ret = 1
	    End If
	End If
	Set objFSO = Nothing

	dirCheck = ret
End Function

'-----------------------------------------
' 編集可能かチェックするメソッド
'-----------------------------------------
Function filePropertyCheck(checkName)
	Dim objFSO, objFile, path

	path = checkName
	Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
	If Err.Number = 0 Then
		'-------------------------------------------
		' ファイルが存在するAND読み取り専用ではない
		' ANDファイルサイズが0ではない時TRUEを返却
		'-------------------------------------------
	    If objFSO.FileExists(path) = True Then
			Set objFile = objFSO.GetFile(path)
			If Not objFile.Attributes = 1 Then
				If Not objFile.Size = 0 Then
					ret = 1
				End If
			End If
	    End If
	End If
	Set objFSO = Nothing

	filePropertyCheck = ret
End Function
'■■■■■■■■■■■■■■■■■■
'■ 関数ここまで                   ■
'■■■■■■■■■■■■■■■■■■