Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I wrote the following VB script in order to run commands from WIN XP on a Linux machine and redirect the output command to out.txt file ( under C:\ )

I don’t understand why output from the command window is not written to out.txt file.

What’s wrong with the line

      Sh.Run "cmd /k  & CMD >> ""C:\out.txt""" , 1, True

My full VB script:

 'TARGET_HOST  - Linux machine

 Const TARGET_HOST = ""
 const PATH =  "cat /etc/hosts" 
 const LOGIN = "root"
 const PASS = " dingdong "
 Const PLINKPATH="""C:\SPUTNIK\plink.exe"""

 Set Sh = CreateObject("WScript.Shell")

        CMD = " echo y | " &   PLINKPATH  & " -ssh -pw " & PASS & LOGIN & "@" & " "   &  TARGET_HOST & " " & PATH 

 Sh.Run "cmd /k  & CMD >> ""C:\out.txt""" , 1, True

  Set Sh = Nothing
share|improve this question
up vote 0 down vote accepted

Right now you are including the CMD variable you created inside the string instead of as a variable.

Try something like:

Sh.Run "cmd /k" & CMD & " >> ""C:\out.txt""" , 1, True

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.