No.425
0
回数0
優先度0
発生日2016/11/21
仮完了
完了日
期限
タイトルフォルダリスト作成
サブタイトルVBScript
内容
rem フォルダ選択画面で選択した任意のフォルダ内のフォルダリストを
rem 現在時刻を付加したCSV形式で既定のフォルダに保存する。
rem 参考
rem http://www.whitire.com/vbs/
rem tips0045.vbs
rem tips0067.vbs
rem tips0082.vbs
rem tips0124.vbs

Option Explicit
On Error Resume Next

Dim objShell ' Shell オブジェクト
Dim objFolder ' フォルダ情報
Dim objFSO ' FileSystemObject
Dim objFile ' ファイル書き込み用
Dim objWinFolder ' ウィンドウズフォルダ

' フォルダ検索関数
Sub FindFolder(ByVal objMainFolder, ByVal strTab)
Dim objSubFolder ' サブフォルダ
For Each objSubFolder In objMainFolder.SubFolders
rem WScript.Echo strTab & "  " & objSubFolder.Name
objFile.WriteLine(strTab & objSubFolder.Name)
FindFolder objSubFolder, "," & strTab
Next
End Sub


Function TimeStamp()
Dim dtmNowDate ' 現在時刻
dtmNowDate = Now()
TimeStamp = _
Year(dtmNowDate) & _
Right("0" & Month(dtmNowDate), 2) & _
Right("0" & Day(dtmNowDate), 2) & _
Right("0" & Hour(dtmNowDate), 2) & _
Right("0" & Minute(dtmNowDate), 2) & _
Right("0" & Second(dtmNowDate), 2)
End Function


'フォルダ取得
Set objShell = WScript.CreateObject("Shell.Application")
If Err.Number = 0 Then
Set objFolder = objShell.BrowseForFolder(0, "通常", 0)
If Not objFolder Is Nothing Then
rem WScript.Echo objFolder.Items.Item.Path

'フォルダリスト作成
Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
If Err.Number = 0 Then
rem Set objWinFolder = objFSO.GetSpecialFolder(1)
Set objWinFolder = objFSO.GetFolder(objFolder.Items.Item.Path)
WScript.Echo objWinFolder.Path & vbCrLf &"のフォルダリストを作成します。"
Set objFile = objFSO.OpenTextFile("D:\" & TimeStamp & "list.csv", 2, True)
If Err.Number = 0 Then

FindFolder objWinFolder, ""

Else
WScript.Echo "ファイルオープンエラー: " & Err.Description
End If
objFile.Close
Else
WScript.Echo "エラー: " & Err.Description
End If
Else
WScript.Echo "エラー: " & Err.Description
End If


rem Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")

Set objWinFolder = Nothing
Set objFSO = Nothing

REM Set objFolder = objShell.BrowseForFolder(0, "Cドライブ", 0, "C:\")
REM If Not objFolder Is Nothing Then
REM WScript.Echo objFolder.Items.Item.Path
REM End If

REM Set objFolder = objShell.BrowseForFolder(0, "スタートメニュー", 0, &HB)
REM If Not objFolder Is Nothing Then
REM WScript.Echo objFolder.Items.Item.Path
REM End If

Else
WScript.Echo "エラー:" & Err.Description
End If

Set objFolder = Nothing
Set objShell = Nothing


Set objFile = Nothing
Set objFSO = Nothing
区分
ステータス
中区分個人
小区分DEV
発生元
発生元担当
対応
対応2
連絡先
対応者新実
URL
0
大区分todo
0
登録日2016-11-21 19:13:04
最終アクセス日2016-11-21 19:13:04
更新日2016-11-21 19:13:04