Evo ti gotova aplikacija.
1. Korisnik unese IP adresu
2. Kreira se folder IP_DATUM
3. Downloaduju se svi fajlovi sa liste
4. Zipuje se ceo folder
Snimi ovo kao fajl sa ekstenzijom .vbs i ako si na Windows7 mašini onda moraš da ga pokreneš kao administrator "Run As Administrator", ili da ga pokreneš preko elevated command prompta komandom "wscript.exe imeskripta.vbs"
Code:
' Get input from the user (IP address)
Dim IP
IP = InputBox( "Enter target IP address:" )
' Establish a Folder name & Create a folder
' Folder Name IP_DATE
Dim myDateString
myDateString = Date()
myDateString = Replace(myDateString, "/", "-") 'Must get rid of / in date, otherwise folder creation will fail
Dim FolderName
FolderName = IP & "_" & myDateString
' Now create a folder
Dim oFSO
Set oFSO = CreateObject("Scripting.FileSystemObject")
oFSO.CreateFolder FolderName
' Download the files
HTTPDownload "http://" & IP & "/netlog0.cap", FolderName
HTTPDownload "http://" & IP & "/netlog1.cap", FolderName
HTTPDownload "http://" & IP & "/scrncap.bmp", FolderName
HTTPDownload "http://" & IP & "/TELog.txt", FolderName
HTTPDownload "http://" & IP & "/deviceinfo.txt", FolderName
HTTPDownload "http://" & IP & "/processsummary.txt", FolderName
HTTPDownload "http://" & IP & "/TelnetLog.txt", FolderName
HTTPDownload "http://" & IP & "/TelnetLog.txt.1", FolderName
HTTPDownload "http://" & IP & "/TelnetLog.txt.2", FolderName
HTTPDownload "http://" & IP & "/TelnetLog.txt.3", FolderName
HTTPDownload "http://" & IP & "/TelnetLog.txt.4", FolderName
' Create archive from the newly created folder
CreateZip FolderName & ".zip", FolderName
' SUBROUTINES
Sub HTTPDownload( myURL, myPath )
' This Sub downloads the FILE specified in myURL to the path specified in myPath.
Dim i, objFile, objFSO, objHTTP, strFile, strMsg
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set objFSO = CreateObject( "Scripting.FileSystemObject" )
If objFSO.FolderExists( myPath ) Then
strFile = objFSO.BuildPath( myPath, Mid( myURL, InStrRev( myURL, "/" ) + 1 ) )
ElseIf objFSO.FolderExists( Left( myPath, InStrRev( myPath, "\" ) - 1 ) ) Then
strFile = myPath
Else
WScript.Echo "ERROR: Target folder not found."
Exit Sub
End If
Set objFile = objFSO.OpenTextFile( strFile, ForWriting, True )
Set objHTTP = CreateObject( "WinHttp.WinHttpRequest.5.1" )
objHTTP.Open "GET", myURL, False
objHTTP.Send
For i = 1 To LenB( objHTTP.ResponseBody )
objFile.Write Chr( AscB( MidB( objHTTP.ResponseBody, i, 1 ) ) )
Next
objFile.Close( )
End Sub
Sub NewZip(pathToZipFile)
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
Dim file
Set file = fso.CreateTextFile(pathToZipFile)
file.Write Chr(80) & Chr(75) & Chr(5) & Chr(6) & String(18, 0)
file.Close
Set fso = Nothing
Set file = Nothing
WScript.Sleep 500
End Sub
Sub CreateZip(pathToZipFile, dirToZip)
'WScript.Echo "Creating zip (" & pathToZipFile & ") from (" & dirToZip & ")"
Dim fso
Set fso= Wscript.CreateObject("Scripting.FileSystemObject")
pathToZipFile = fso.GetAbsolutePathName(pathToZipFile)
dirToZip = fso.GetAbsolutePathName(dirToZip)
If fso.FileExists(pathToZipFile) Then
'WScript.Echo "That zip file already exists - deleting it."
fso.DeleteFile pathToZipFile
End If
If Not fso.FolderExists(dirToZip) Then
'WScript.Echo "The directory to zip does not exist."
Exit Sub
End If
NewZip pathToZipFile
dim sa
set sa = CreateObject("Shell.Application")
Dim zip
Set zip = sa.NameSpace(pathToZipFile)
Dim d
Set d = sa.NameSpace(dirToZip)
' Look at http://msdn.microsoft.com/en-us/library/bb787866(VS.85).aspx
' for more information about the CopyHere function.
zip.CopyHere d.items, 4
Do Until d.Items.Count <= zip.Items.Count
Wscript.Sleep(200)
Loop
End Sub
[Ovu poruku je menjao ventura dana 13.10.2012. u 14:27 GMT+1]