25 aug 2009

comments to files via the windows explorer

the reg file :

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\AllFilesystemObjects]

[HKEY_CLASSES_ROOT\AllFilesystemObjects\shell]

[HKEY_CLASSES_ROOT\AllFilesystemObjects\shell\CommentFile]

[HKEY_CLASSES_ROOT\AllFilesystemObjects\shell\CommentFile\command]
@="cscript c:\\listdoc.vbs %1"


the vbscript file

LogDirectory = "C:\"
strLogName = "listfile.csv"


nota = InputBox("nota" ,"nota","")
Set args = WScript.Arguments
arg1 = args.Item(0)
Append_File(arg1 & ";" & nota)

' -------------------------------------------------------
' Append_File
' -------------------------------------------------------


Function Append_File(txt_info)
On Error Resume Next
Dim objFileSystem, objOutputFile
Const OPEN_FILE_FOR_APPENDING = 8
strOutPutFile = LogDirectory & strLogName

Set objFileSystem = CreateObject("Scripting.fileSystemObject")

If objFileSystem.FileExists(strOutPutFile) Then
Set objOutputFile = objFileSystem.OpenTextFile(strOutPutFile, OPEN_FILE_FOR_APPENDING)
Else
Set objOutputFile = objFileSystem.CreateTextFile(strOutPutFile, True)
End If

objOutputFile.WriteLine (Now & ";" & txt_info)


objOutputFile.Close
Set objFileSystem = Nothing
End Function