user3727850
user3727850

Reputation: 143

How to enter password in command promt using vbscript

I have written vb script code to copy files from Windows to Linux using putty PSCP command

Dim objShell
Set objShell = WScript.CreateObject ("WScript.shell")
objShell.run "cmd /K pscp.exe c:\temp\sunset.jpg tokunbo@my-ipaddress:/home/tokunbo"
Set objShell = Nothing

When i am running above script,i am getting tokunbo@my-ipaddress password: option in command promt. My question how to write code to enter password in command prompt in vbscript. Please help

Upvotes: 0

Views: 1045

Answers (1)

Ansgar Wiechers
Ansgar Wiechers

Reputation: 200453

When in doubt, read the documentation:

Usage: pscp [options] [user@]host:source target
       pscp [options] source [source...] [user@]host:target
       pscp [options] -ls [user@]host:filespec
Options:
  -V        print version information and exit
  -pgpfp    print PGP key fingerprints and exit
  -p        preserve file attributes
  -q        quiet, don't show statistics
  -r        copy directories recursively
  -v        show verbose messages
  -load sessname  Load settings from saved session
  -P port   connect to specified port
  -l user   connect with specified username
  -pw passw login with specified password
  -1 -2     force use of particular SSH protocol version
  -4 -6     force use of IPv4 or IPv6
  -C        enable compression
  -i key    private key file for authentication
  -noagent  disable use of Pageant
  -agent    enable use of Pageant
  -batch    disable all interactive prompts
  -unsafe   allow server-side wildcards (DANGEROUS)
  -sftp     force use of SFTP protocol
  -scp      force use of SCP protocol

I would, however, recommend using public key authentication instead of password authentication.

Upvotes: 1

Related Questions