Spis treści: (ukryj)

  1. 1. Scripting.FileSystemObject
  2. 2. CheckCScript
  3. 3. Changing File Extensions

1.  Scripting.FileSystemObject

Pozwala na manipulacje plikami itp. Tworzony przez:

Set fso = CreateObject("Scripting.FileSystemObject")

Niektóre ważne metody:

2.  CheckCScript

na podstawie microsoft.public.de.german.scripting.wsh

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

3.  Changing File Extensions

źródło: www.activexperts.com

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