VBS – Save to text file entire command line

Home Forums Scripting General Scripting VBS – Save to text file entire command line

This topic contains 2 replies, has 3 voices, and was last updated by Avatar strjohn 1 year, 8 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • Avatar


    I am new to VBS and I was assigned to write a code that will simplify a task. My problem is that I do not know how to save this entire Command line to a text file. Then the result of showconfig -l will be used on the next function. I have been trying several methods but no luck. BTW this getin.CMD will only run unless you directly point the drive where it was located so I used sendkeys to do the job.

    Here is my code:


    Set fso = CreateObject(“Scripting.FileSystemObject”)
    Set objShell = WScript.CreateObject(“WScript.Shell”)

    location = “D:env”
    fname =”getIn.cmd”

    enter fso.GetFolder(location)
    dim fldr, f

    Function enter(fldr)
    For Each f In fldr.Files
    If LCase(f.Name) = fname Then

    ‘wscript.Echo f.name & ” exists”
    ‘Wscript.Echo fldr & ” Folder”
    objShell.sendkeys “D:”
    WScript.Sleep 1000
    objShell.sendkeys “{Enter}”

    objShell.sendkeys “cd ” & fldr
    WScript.Sleep 1000
    objShell.sendkeys “{Enter}”

    objShell.sendkeys fname
    WScript.Sleep 1000
    objShell.sendkeys “{Enter}”

    objShell.sendkeys “showconfig -l”
    WScript.Sleep 1000
    objShell.sendkeys “{Enter}”

    ‘Wscript.Echo “Cannot find getInCMD”
    End If
    For Each sf In fldr.SubFolders
    enter sf

    End function


    Thank you in Advance. :)


    What is it that your trying to achieve?

    From the looks of it you are trying to run a batch file, getln.cmd, from a location that isn’t the one you are in??

    I’m assuming that the getln.cmd contains the showconfig -l command?

    Really should be something as simple as this

    Dim objShell
    Set objShell = WScript.CreateObject(“WScript.Shell”)
    objShell.Run “d:Envgetln.cmd”[/CODE][CODE]Dim objShell
    Set objShell = WScript.CreateObject(“WScript.Shell”)
    objShell.Run “d:Envgetln.cmd”[/CODE]


    Hi thanks for quick response,

    getin.cmd will set environment variable and locate the list of commands available. BTW this “showconfig -l” command will only work unless getin.cmd is triggered. So after typing “showconfig -l”, list of application properties will appear. Then from that properties I need to identify if a particular attribute is “ON” or “OFF”, so that is why I want to save it on a text file then read the text file if it is ON or OFF.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

Register for this Petri Webinar!

Want to Make Your Backup Storage Unlimited & Ready for the Cloud? – Free Thurrott Premium Account with Webinar Registration!

Tuesday, August 27, 2019 @ 1:00 pm EDT

A Scale-Out Backup storage infrastructure is a must-have technology for your backups. In this webinar, join expert Rick Vanover for a look on what real-world problems are solved by the Scale-Out Backup Repository.

Register Now

Sponsored By