Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: STDOUT pipe piping data > >>
See Also: Get results from STDOUT - UDF (Option~2)
References:
The following example was designed for Windows XP.
NOTE: The WScript object is the root object of the Windows Script Host object model hierarchy.
#DefineFunction GetSTDOUT(cmd) objShell = ObjectOpen("WScript.Shell") objWshScriptExec = objShell.Exec(cmd) objStdOut = objWshScriptExec.StdOut line = objStdOut.ReadAll objStdOut = 0 objWshScriptExec = 0 objShell = 0 Return line #EndFunction ;Vol ;Displays the disk volume label and serial number, if they exist. A serial number is displayed for a disk ;formatted with MS-DOS version 4.0 or later. cmd = 'cmd /c vol c:' data = GetSTDOUT(cmd) Message(StrCat(cmd," - STDOUT"), data) ;Ver ;Displays the Windows XP version number. cmd = 'cmd /c ver' data = GetSTDOUT(cmd) Message(StrCat(cmd," - STDOUT"), data) ;Tree ;Graphically displays the directory structure of a path or of the disk in a drive. DirChange(Dirwindows(0)) cmd = 'cmd /c tree /a' data = GetSTDOUT(cmd) Message(StrCat(cmd," - STDOUT"), data) ;Tracert ;Determines the path taken to a destination by sending Internet Control Message Protocol (ICMP) Echo Request ;messages to the destination with incrementally increasing Time to Live (TTL) field values. The path displayed ;is the list of near-side router interfaces of the routers in the path between a source host and a destination. ;The near-side interface is the interface of the router that is closest to the sending host in the path. cmd = 'tracert www.winbatch.com' data = GetSTDOUT(cmd) Message(StrCat(cmd," - STDOUT"), data) ;Tasklist ;Displays a list of applications and services with their Process ID (PID) for all tasks running on either a local or a remote computer. cmd = 'Tasklist' data = GetSTDOUT(cmd) Message(StrCat(cmd," - STDOUT"), data) ;Systeminfo ;Displays detailed configuration information about a computer and its operating system, including operating ;system configuration, security information, product ID, and hardware properties, such as RAM, disk space, and network cards. cmd = 'systeminfo' data = GetSTDOUT(cmd) Message(StrCat(cmd," - STDOUT"), data) ;Schtasks ;Schedules commands and programs to run periodically or at a specific time. Adds and removes tasks from the schedule, ;starts and stops tasks on demand, and displays and changes scheduled tasks. ;Displays all tasks scheduled to run on the computer, including those scheduled by other users. cmd = 'Schtasks' data = GetSTDOUT(cmd) Message(StrCat(cmd," - STDOUT"), data) ;Route ;Displays and modifies the entries in the local IP routing table. ;To display the entire contents of the IP routing table, type: cmd = 'route print' data = GetSTDOUT(cmd) Message(StrCat(cmd," - STDOUT"), data) ;Prnport.vbs ;Creates, deletes, and lists standard TCP/IP printer ports, in addition to displaying and changing port configuration. DirChange("C:\WINDOWS\system32\") cmd = '"cscript" "Prnport.vbs" -l' data = GetSTDOUT(cmd) Message(StrCat(cmd," - STDOUT"), data) ;Prnmngr.vbs ;Adds, deletes, and lists printers or printer connections, in addition to setting and displaying the default printer. ;Used without parameters, prnmngr.vbs displays command-line help for the prnmngr.vbs command. ;To list all of the printers for a computer DirChange("C:\WINDOWS\system32\") cmd = '"cscript" "prnmngr.vbs" -l' data = GetSTDOUT(cmd) Message(StrCat(cmd," - STDOUT"), data) ;Prnjobs.vbs ;Pauses, resumes, cancels, and lists print jobs. ;To list the print jobs in a print queue DirChange("C:\WINDOWS\system32\") cmd = '"cscript" "prnjobs.vbs" -l' data = GetSTDOUT(cmd) Message(StrCat(cmd," - STDOUT"), data) ;Prndrvr.vbs ;Adds, deletes, and lists printer drivers. ;To list the printer drivers on a computer DirChange("C:\WINDOWS\system32\") cmd = '"cscript" "prndrvr.vbs" -l' data = GetSTDOUT(cmd) Message(StrCat(cmd," - STDOUT"), data) ;Prncnfg.vbs ;Configures or displays configuration information about a printer. Used without parameters, prncnfg.vbs ;displays command-line help for the prncnfg.vbs command. ;To display configuration information about a printer if FileLocate("WWPRT34i.DLL") != "" AddExtender("WWPRT34i.DLL") defprt = pGetDefPrtInf(1) DirChange("C:\WINDOWS\system32\") cmd = StrCat('"cscript" "prncnfg.vbs" -g -p "',defprt,'"') data = GetSTDOUT(cmd) Message(StrCat(cmd," - STDOUT"), data) endif ;Nslookup ;Displays information that you can use to diagnose Domain Name System (DNS) infrastructure. Before using ;this tool, you should be familiar with how DNS works. The Nslookup command-line tool is available only if ;you have installed the TCP/IP protocol. cmd = "Nslookup ls" data = GetSTDOUT(cmd) Message(StrCat(cmd," - STDOUT"), data) ;Netstat ;Displays active TCP connections, ports on which the computer is listening, Ethernet statistics, ;the IP routing table, IPv4 statistics (for the IP, ICMP, TCP, and UDP protocols), and IPv6 statistics ;(for the IPv6, ICMPv6, TCP over IPv6, and UDP over IPv6 protocols). Used without parameters, netstat ;displays active TCP connections. ;Displays all active TCP connections and the TCP and UDP ports on which the computer is listening. cmd = "Netstat -a" data = GetSTDOUT(cmd) Message(StrCat(cmd," - STDOUT"), data) ;Displays Ethernet statistics, such as the number of bytes and packets sent and received. cmd = "Netstat -e" data = GetSTDOUT(cmd) Message(StrCat(cmd," - STDOUT"), data) ;Displays active TCP connections, however, addresses and port numbers are expressed numerically and ;no attempt is made to determine names. cmd = "Netstat -n" data = GetSTDOUT(cmd) Message(StrCat(cmd," - STDOUT"), data) ;Displays the contents of the IP routing table. This is equivalent to the route print command. cmd = "Netstat -r" data = GetSTDOUT(cmd) Message(StrCat(cmd," - STDOUT"), data) ;Ipxroute ;To display the network segments that the workstation is attached to, the workstation node address, ;and frame type being used cmd = "ipxroute config" data = GetSTDOUT(cmd) Message(StrCat(cmd," - STDOUT"), data) ;Net statistics ;Displays the statistics log for the local Workstation or Server service, or the running services for which ;statistics are available. Used without parameters, net statistics lists the running services for which ;statistics are available. cmd = "cmd.exe /c net statistics workstation" data = GetSTDOUT(cmd) Message(StrCat(cmd," - STDOUT"), data) ;Date ;Displays the current system date setting. Used without parameters, date displays the current system date ;setting and prompts you to type a new date. cmd = "cmd.exe /c date /t" data = GetSTDOUT(cmd) Message(StrCat(cmd," - STDOUT"), data) ;Net view ;Displays a list of domains, computers, or resources that are being shared by the specified computer. ;Used without parameters, net view displays a list of computers in your current domain. cmd = "cmd.exe /c net view" data = GetSTDOUT(cmd) Message(StrCat(cmd," - STDOUT"), data) ;Ipconfig ;Displays all current TCP/IP network configuration values and refreshes Dynamic Host Configuration Protocol ;(DHCP) and Domain Name System (DNS) settings. Used without parameters, ipconfig displays the IP address, ;subnet mask, and default gateway for all adapters. cmd = "ipconfig /all" data = GetSTDOUT(cmd) Message(StrCat(cmd," - STDOUT"), data) ;nbtstat ;To display the NetBIOS name table of the local computer cmd = 'nbtstat -n' data = GetSTDOUT(cmd) Message(StrCat(cmd," - STDOUT"), data) ;Getmac ;Returns the media access control (MAC) address and list of network protocols associated with each address for all network ;cards in each computer, either locally or across a network. cmd = 'Getmac' data = GetSTDOUT(cmd) Message(StrCat(cmd," - STDOUT"), data) ;FC - File Compare ;To make an ASCII comparison of two text files that are named Monthly.rpt and Sales.rpt and display the results in abbreviated format, ; fc /a monthly.rpt sales.rpt ;To make a binary comparison of two batch files named Profits.bat and Earnings.bat, type: ; fc /b profits.bat earnings.bat DirChange("C:\temp\data\") cmd = 'fc /a C:\Temp\Data\test.txt C:\Temp\Data\test2.txt' data = GetSTDOUT(cmd) Message(StrCat(cmd," - STDOUT"), data) ;Eventquery ;Lists the events and event properties from one or more event logs. DirChange("C:\WINDOWS\system32\") cmd = '"cscript.exe" eventquery.vbs /l application' data = GetSTDOUT(cmd) Message(StrCat(cmd," - STDOUT"), data) ;Driverquery ;Displays a list of all installed device drivers and their properties. cmd = "driverquery" data = GetSTDOUT(cmd) Message(StrCat(cmd," - STDOUT"), data) ;Ping ;Verifies IP-level connectivity to another TCP/IP computer by sending Internet Control Message Protocol (ICMP) ;Echo Request messages. The receipt of corresponding Echo Reply messages are displayed, along with round-trip times. ;Ping is the primary TCP/IP command used to troubleshoot connectivity, reachability, and name resolution. Used ;without parameters, ping displays help. cmd = "ping www.winbatch.com" data = GetSTDOUT(cmd) Message(StrCat(cmd," - STDOUT"), data)
Article ID: W16228
File Created: 2014:07:18:09:51:40
Last Updated: 2014:07:18:09:51:40