Dag allemaal,
Ik heb samen met een paar gevonden scripts op internet een script samengesteld, maar hij wil niet werken. Weet er iemand een oplossing?
Ik heb samen met een paar gevonden scripts op internet een script samengesteld, maar hij wil niet werken. Weet er iemand een oplossing?
Code:
Option Explicit
' Constants for GetSpecialFolder(), derived from the scrrun.dll type library where the Scripting.FileSystemObject
' class is defined.
Const SystemFolder = 1
Const TemporaryFolder = 2
Const WindowsFolder = 0
Dim fso
Dim fileToCopy
Dim destinationPath
Dim dontDelete
Set fso = CreateObject("Scripting.FileSystemObject";)
fileToCopy = "C:\hello.txt"
destinationPath = fso.GetSpecialFolder(WindowsFolder).Path & "\newname.123"
'Create file to copy if it does not exist.
If Not fso.FileExists(fileToCopy) Then
Dim textStream
Set textStream = fsoCreateTextFile("C:\hello.txt";)
textStream.WriteLine "I am a file."
textStream.Close
Set textStream = nothing
Else
dontDelete = True
End If
'Copy file to Windows directory with a new file name and extension.
'This will destroy any file called "newname.123" in the Windows directory.
fso.CopyFile fileToCopy, destinationPath, True
'Delete copy.
fso.DeleteFile destinationPath, True
'Only delete original if it was not created by this script.
If Not dontDelete Then fso.DeleteFile destinationPath
'Some house cleaning...
Set fso = Nothing