> WSH > psexec.exe TrueCrypt, ,

psexec.exe TrueCrypt, ,


13 2012. : dimon
psexec.exe TrueCrypt, , .
.
psexec.exe .

'----------------------------------------------------------------------
'
' Copyright (c)All rights reserved.
'
'
' AUTHOR: tudimon.com
' DATE: 13.09.2012
' NAME: TrueCrypt_mount_copy_unmount_v1.vbs
'
' COMMENT:
'
' psexec.exe TrueCrypt, , .
'
' .
'
' psexec.exe .
'
'
'----------------------------------------------------------------------

'

SourceFolder = "D:\data" ' ( )
DestinationFolder = "\\192.168.1.122\data" ' ( )

LogFilePath = "D:\logs\"' -
LogTXT = "" '

' psexec.exe
ipTarget = "192.168.1.122"' ip ()
psUser = "domain\adm"'
psPass = "sec_password"'

' TrueCrypt
tcPath = "c:\Progra~1\TrueCrypt\TrueCrypt.exe"' TrueCrypt.exe
tcTarget = "\Device\Harddisk2\Partition1"'
tcLetter = "l"'
tcPass = "tc_secret_password"'


'----------------------------------------------------------------------

LogTXT = LogTXT & vbNewLine & "******************** " & Now & " ********************"

'
DateTimeStamp = Year(now) & Right("00" & CStr(Month(Now)), 2) & Right("00" & CStr(Day(Now)), 2) & "_"& Right("00" & CStr(Hour(Now)), 2) & "-"& Right("00" & CStr(Minute(Now)), 2) & "-"& Right("00" & CStr(Second(Now)), 2)

' -
LogFilePath = LogFilePath & "TC_" & DateTimeStamp & ".txt"

'MsgBox LogFilePath

' psexec.exe
cmdPS = "psexec.exe \\" & ipTarget & " -u " & psUser & " -p " & psPass & " "

' ****

' TC mount
cmdTC = tcPath & " /q /v " & tcTarget & " /l" & tcLetter & " /p """ & tcPass & """"

'
Set objShell = CreateObject("WScript.Shell")
Set objScriptExec = objShell.Exec(cmdPS & cmdTC)
LogTXT = LogTXT & vbNewLine & " mount " & tcLetter & ":\ disk" & vbNewLine


' ****

' 60 ,
WScript.sleep 60000


'
'DestinationFolder = DestinationFolder & "\" & Year(now) & Right("00" & CStr(Month(Now)), 2) & Right("00" & CStr(Day(Now)), 2)

LogTXT = LogTXT & vbNewLine & "******************** " & Now & " ********************"

LogTXT = LogTXT & vbNewLine & "Destination Folder is " & DestinationFolder & vbNewLine



' ****
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(SourceFolder)
Set colFiles = objFolder.Files
For Each objFiles in colFiles

If objFiles.Attributes and 32 Then
' ,
objFSO.CopyFile objFiles.Path, DestinationFolder & "\" & objFiles.Name

' 2log
LogTXT = LogTXT & vbNewLine & objFiles.Path & " copy done"

'
objFiles.Attributes = objFiles.attributes - 32

End If

Next




' ****

' 60
WScript.sleep 60000

' TC unmount
cmdTC = tcPath & " /q /d" & tcLetter & " /f /s"

'
Set objShell = CreateObject("WScript.Shell")
Set objScriptExec = objShell.Exec(cmdPS & cmdTC)
LogTXT = LogTXT & vbNewLine & " unmount " & tcLetter & ":\ disk" & vbNewLine




' ****
Set FSO = CreateObject("Scripting.FileSystemObject")
Set LogFile = FSO.OpenTextFile(LogFilePath, 8, True)
LogTXT = LogTXT & vbNewLine & "*************************************************************"
LogFile.WriteLine LogTXT
LogFile.Close

Set FSO = Nothing
Set objFSO = Nothing

WScript.Quit 0