Foldercopy mit GUI

Das kleine Script kopiert Ordner.

Die Angabe der Ordner wird als Befehlszeilenparameter erwartet:

set oArgs=wscript.Arguments
quelle = oargs(0)
ziel = oargs(1)

Der Inhalt von C:\Program Files\Microsoft Office wird dann nach C:\Temp kopiert. Und es passiert etwas auf dem Bildschirm.

 

option explicit

dim quelle, ziel, oargs, shellapp, oZielOrdner

set oArgs=wscript.Arguments

if oArgs.Count <1 then
wscript.echo VBCRLF & "! Error !" & VBCRLF & "! Missing argument !"
wscript.quit
End if

quelle = oargs(0)
ziel = oargs(1)

Sub ShellFolderCopy ()

Dim WSHShell : Set WSHShell = WScript.CreateObject("WScript.Shell")
Dim fso : Set fso      = WScript.CreateObject("Scripting.FileSystemObject")

'fso.CopyFolder Quelle, Ziel, True  # ..... wird nicht benötigt

    Set ShellApp    = CreateObject("Shell.Application")
    Set oZielOrdner = ShellApp.NameSpace( Ziel )

    oZielOrdner.CopyHere Quelle , 272 'vOptions

    Set ShellApp    = nothing ' weil es nicht mehr gebraucht wird
    Set oZielOrdner = nothing
end sub

shellfoldercopy()

  • Mittwoch, 14 März 2018

Leave a comment

You are commenting as guest.