[VB Script] DateiAuswahl Dialog

batch_prog

Cadet 2nd Year
Registriert
März 2017
Beiträge
27
Hi,

kann mir jemand von Euch helfen,wie ich nachfolgenden Datei Auswahl Dialog mit dem darunter stehende Code verbinden kann und die in der Quelle benötigten Datei durch den Auswahl Dialog in das Verzeichnis kopieren kann? Am liebsten würde ich den Dialog noch auf csv begrenzen.

Code:
Option Explicit

Dim strFile

strFile = SelectFile( )

If strFile = "" Then 
'    WScript.Echo "No file selected."
Else
    WScript.Echo """" & strFile & """"
End If


Function SelectFile( )
   
    Dim objExec, strMSHTA, wshShell

    SelectFile = ""


    strMSHTA = "mshta.exe ""about:" & "<" & "input type=file id=FILE>" _
             & "<" & "script>FILE.click();new ActiveXObject('Scripting.FileSystemObject')" _
             & ".GetStandardStream(1).WriteLine(FILE.value);close();resizeTo(0,0);" & "<" & "/script>"""


    Set wshShell = CreateObject( "WScript.Shell" )
    Set objExec = wshShell.Exec( strMSHTA )

    SelectFile = objExec.StdOut.ReadLine( )

    Set objExec = Nothing
    Set wshShell = Nothing
End Function

Code:
Dim WshShell  : Set WshShell = CreateObject("Wscript.Shell")
Dim FSO : Set FSO = CreateObject("Scripting.FileSystemObject")
'temporäre Batch-Datei erzeugen
Dim Batch1 : Batch1 = WshShell.ExpandEnvironmentStrings("%userprofile%") & "\Desktop\Test\Temp\" & FSO.GetTempName & ".cmd"
With FSO.CreateTextFile(Batch1, True)
  .WriteLine "@ECHO off"
  .WriteLine "SETLOCAL enabledelayedexpansion"
  .WriteLine "SET quelle=%userprofile%\Desktop\Test\csv-sicherung-%Date%.csv"
  .WriteLine .......
  .Close
End With
'temporäre Batch-Datei ausführen, auf Ende warten
WshShell.Run Batch1, 0, True
'temporäre Batch-Datei löschen
FSO.DeleteFile Batch1, True

Beste Grüße!
 
Zurück
Oben