Frage

i have written a program which calculates the HASH of all files of a folder and saves it an an xml file. now my objective is that i want to give the folder to be evaluated, explicitly from outside the program

  Dim WshShell, oExec, input
Set WshShell = CreateObject("WScript.Shell")
Set oExec    =_
     WshShell.exec("C:\Users\Administrator\Downloads\fciv.exe -md5 -r -xml _
     d.xml C:\openssl")

 input = ""

 Do While oexec.status=0


 WScript.Sleep 5000
 Loop

this is the program. i tried adding inputbox command thinking i would be able to give the input explicitly. here is the modified program

 Dim WshShell, oExec, strin
 Set WshShell = CreateObject("WScript.Shell")
 strin= inputbox("folder")
 Set oExec    =_
  WshShell.exec("C:\Users\Administrator\Downloads\fciv.exe -md5 -r -xml ex.xml strin")
 input = ""
 Do While oexec.status=0*

 WScript.Sleep 1000
 Loop

this is not working :( pls help. what exactly shud i be using thr? also how do i give the same input using a cmd file???

War es hilfreich?

Lösung

You just need to use the string concatenation operator & to build the command string:

 Dim WshShell, oExec, strin
 Set WshShell = CreateObject("WScript.Shell")
 strin= inputbox("folder")
 Set oExec    =_
  WshShell.exec("C:\Users\Administrator\Downloads\fciv.exe -md5 -r -xml ex.xml """ & strin & """")
 input = ""
 Do While oexec.status=0
     WScript.Sleep 1000
 Loop

I took the liberty of adding the appropriate double-quotes in case the input path has spaces. You might want to also add in some validation of the path, eg:

dim fso: set fso = CreateObject("Scripting.FileSystemObject")
if not fso.FolderExists(strin) then
     WScript.Echo strin & " not found"
     WScript.Quit 1
end if
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top