Spis treści: (ukryj)
Pozwala na manipulacje plikami itp. Tworzony przez:
Set fso = CreateObject("Scripting.FileSystemObject")
Niektóre ważne metody:
Set file = CreateTextFile( name, overwrite=True ) file.WriteLine(...), file.Close)
CreateFolder( name )
Sprawdza, czy skrypt uruchomiono za pomocą wscript.exe czy cscript.exe
Function CheckCScript intPos = InStrRev(WScript.FullName, "\") strHost = LCase(Mid(WScript.FullName, intPos + 1)) CheckCScript = ( LCase(strHost) = "cscript.exe" ) End Function
Changes the file extension for all the .log files in the C:\Scripts folder to .txt.
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set FileList = objWMIService.ExecQuery _
("ASSOCIATORS OF {Win32_Directory.Name='c:\Scripts'} Where " _
& "ResultClass = CIM_DataFile")
For Each objFile In FileList
If objFile.Extension = "log" Then
strNewName = objFile.Drive & objFile.Path & _
objFile.FileName & "." & "txt"
errResult = objFile.Rename(strNewName)
Wscript.Echo errResult
End If
Next