Using VBScript (run through cscript
), how can I call another command program (pscp
in this case), which also requires user input, etc.?
The purpose is that the initial VBScript will gather the parameters (password, user, etc.), then the pscp
command
pscp -r -pw password copyFromPath user@host:copyToPath
can be issued and the user will be able to see the output from the pscp command, as well as being able to input (if, for example, they gave the wrong password and are required to input it again).
I currently have:
' create the command, that calls pscp from cmd
Dim comSpec : comSpec = objShell.ExpandEnvironmentStrings("%comspec%")
Dim command : command = comspec & " /C " & """" & "pscp -r -pw " & "^""" & (Replace(pscpPassword,"""","\^""")) & "^"" " _
& "^""" & (windowsPath) & "^"" " _
& pscpUser & "@" & pscpHostName & ":" & Replace(linuxPath," ","\ ") & """"
Dim objExec : Set objExec = objShell.Exec(command)
An alternative I came up with for generating command
was:
Dim command : command = "pscp -r -pw " & Chr(34) & Replace(pscpPassword,"""","\""") & Chr(34) & " " _
& Chr(34) & windowsPath & Chr(34) & " " _
& pscpUser & "@" & pscpHostName & ":" & Replace(linuxPath," ","\ ")
But neither of these allow me to interact with pscp
once it's called.
Edit
The fact that I'm calling pscp
is almost irrelevant. I could be calling any program which asks for user input and displays things to stdout
and stderr