Coming Soon: GET:IT Endpoint Management 1-Day Conference on September 28th at 9:30 AM ET Coming Soon: GET:IT Endpoint Management 1-Day Conference on September 28th at 9:30 AM ET

VBS – Save to text file entire command line

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

Viewing 1 post (of 1 total)
  • Author
    Posts

  • lechung21
    Member
    #167351

    Hello,

    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}”

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

    Next
    End function

    ************************************

    Thank you in Advance. :)

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

Live Webinar: Active Directory Security: What Needs Immediate Priority!Live on Tuesday, October 12th at 1 PM ET

Attacks on Active Directory are at an all-time high. Companies that are not taking heed are being punished, both monetarily and with loss of production.

In this webinar, you will learn:

  • How to prioritize vulnerability management
  • What attackers are leveraging to breach organizations
  • Where Active Directory security needs immediate attention
  • Overall strategy to secure your environment and keep it secured

Sponsored by: