Question

Pass html form data to shell_exec

Asked by: richrumble

I'd like to have a very simple form that feeds a command line script. The form should pass user/pass, ip (or FQDN) and have a few checkboxes buttons for selections...
currently the script is static, the input is like this:
cscript /nologo inv.vbs /s:ip.ip.ip.ip  /u:user_name /p:password /c:hd/bios/mem
I'd think it could be something like:
cscript /nologo inv.vbs /s:$fqdn  /u:$user /p:$pass /c:$hd,$bios,$mem (if all 3 are checked)

It should be pretty simple, I can tweak the output to make it compliant and pretty.

<?PHP
$output = shell_exec('cscript /nologo c:\scripto\inv.vbs /s:server_01 /u:domain\user_02 /p:"asdfqwerty"' /c::hd,bios,mem);
echo "<pre>$output</pre>";
?>

                                  
1:
2:
3:
4:

Select allOpen in new window

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-06-08 at 18:41:27ID24474226
Tags

php

,

cli

,

vbscript

Topics

PHP Scripting Language

,

PHP for Windows

Participating Experts
2
Points
500
Comments
6

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. shell script, feed telnet, rlogin, or rsh with login
    I'm writing a simple bourne shell script to connect to a host and execute a command, say, ls. When I run the script, I provide the username at command line. The problem is telnet prompts for username and passwd. I want to use the username I already have, say, in a variable, t...
  2. cscript from ASP
    I'm trying to call a vbs file from ASP and need to read the output the call returns using IIS 5 on windows 2000 I would like to call the Windows Media Command Line Encoder and convert audio file bitrates http://msdn.microsoft.com/library/en-us/wmencode/htm/commandlinesample....
  3. Wscript.Shell and cscript engin will not terminate
    I have an ASP page that uses the wshShell object and the Run method to run a wsf script on the host server. Both the ASP page and the wsf script runs fine and returns no errors however the cscript.exe process that Windows2000 Server uses to execute the wsf script does not ter...
  4. Shell_exec problem!!!
    Hi all; Well, I need to run a BAT application that is in the server. I'm able to run shell commands as DIR, CD or so, but when I execute the bat for the commerce application, it just opens a windows in order to download page.php...¿?¿?¿?...I'm bothered... why the system is ...
  5. Problems with CSCRIPT and VISTA
    I have an Access application that runs a CSCRIPT script (which happens to control an external device, but I don't think that's relevant), and within the code there are different paths to follow for each version of Windows: eg. If [winver] = 98 Then [CommandLine] = "comm...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: cxrPosted on 2009-06-08 at 19:06:25ID: 24577764

This should get you started:

<?PHP
if($_POST) {
  $fqdn = $_POST['fqdn'];
  $user = $_POST['user'];
  $pass = $_POST['pass'];
  $hd = $_POST['hd'];
  $bios = $_POST['bios'];
  $mem = $_POST['mem'];
  $output = shell_exec("cscript /nologo inv.vbs /s:$fqdn  /u:$user /p:$pass /c:$hd,$bios,$mem");
  echo "<pre>$output</pre>";
}
?>
<form method="post">
fqdn/ip: <input type="text" name="fqdn" /><br />
user: <input type="text" name="user" /><br />
pass: <input type="text" name="pass" /><br />
hd: <input type="text" name="hd" /><br />
bios: <input type="text" name="bios" /><br />
mem: <input type="text" name="mem" /><br />
<input type="submit" value="Execute" />
</form>

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:

Select allOpen in new window

 

by: richrumblePosted on 2009-06-08 at 19:22:47ID: 24577815

So far so good, I made a few changes, see below. I'd like to better handle the checkboxes. Leaving one unchecked, like bios, might lead to an extra comma in the /c: parameters
Notice: Undefined index: bios in C:\wamp\www\tools\index.php on line 7

might need an "if checked"
Also if nothing is checked, I'd like the /c: to be removed...
if nothing checked shell_exec("cscript /nologo c:\scripto\inv.vbs /s:$fqdn  /u:$user /p:\"$pass\"
user, pass and fqdn (or IP) are required field can we check for that... after that this is all done!
-rich

<?PHP
if($_POST) {
  $fqdn = $_POST['fqdn'];
  $user = $_POST['user'];
  $pass = $_POST['pass'];
  $hd = $_POST['hd'];
  $bios = $_POST['bios'];
  $mem = $_POST['mem'];
  $output = shell_exec("cscript /nologo c:\scripto\inv.vbs /s:$fqdn  /u:$user /p:\"$pass\" /c:$hd,$bios,$mem");
  echo "<pre>$output</pre>";
}
?>
<form method="post">
fqdn/ip: <input type="text" name="fqdn" /><br />
user: <input type="text" name="user" /><br />
pass: <input type="text" name="pass" /><br />
hd:  <input type="checkbox" name="hd" value="hd" /><br />
bios: <input type="checkbox" name="bios" value="bios" /><br />
mem: <input type="checkbox" name="mem" value="mem" /><br />
<input type="submit" value="Execute" />
</form>

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:

Select allOpen in new window

 

by: szewkamPosted on 2009-06-08 at 19:52:54ID: 24577921

it's all about handling every variable ;)
The code below should work :)

<?PHP
if($_POST) {
  $fqdn = $_POST['fqdn'];
  $user = $_POST['user'];
  $pass = $_POST['pass'];
  $hd = $_POST['hd'];
  $bios = $_POST['bios'];
  $mem = $_POST['mem'];
  if (empty($fqdn) || empty($user) || empty($pass)) {
    echo "Fields fqdn, user and pass are required";
    exit;
  }
  $par = array();
  if (isset($hd)) $par[] = "hd";
  if (isset($biod)) $par[] = "bios";
  if (isset($mem)) $par[] = "mem";
  $txt = empty($par) ? '' : '/c:'.implode(',', $par);
  $output = shell_exec("cscript /nologo c:\scripto\inv.vbs /s:$fqdn  /u:$user /p:\"$pass\" $txt");
  echo "<pre>$output</pre>";
}
?>
<form method="post">
fqdn/ip: <input type="text" name="fqdn" /><br />
user: <input type="text" name="user" /><br />
pass: <input type="text" name="pass" /><br />
hd:  <input type="checkbox" name="hd" value="hd" /><br />
bios: <input type="checkbox" name="bios" value="bios" /><br />
mem: <input type="checkbox" name="mem" value="mem" /><br />
<input type="submit" value="Execute" />
</form>

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:

Select allOpen in new window

 

by: richrumblePosted on 2009-06-09 at 04:07:38ID: 24579860

Still getting the undefined variable for lines 6,7,8 depending on which checkboxes are unchecked. If all 3 are unchecked all 3 are undfined, if 2 are not checked those two are undefined...
Here is the script I'm calling if that helps.

-rich

' Usage:
'cscript /nologo inventory.vbs /s:ip.ip.ip.ip  /u:user_name /p:password /c:hd,pc,bios,vid,mem,nic,cpu,hwerr,os,av,fw
' ip's can be comma seperated... ip's could also be dns-name(s)
' if no parametes are given local host and all parameters are run...
Const WbemAuthenticationLevelPktPrivacy = 6
 
 
Function WMIDateStringToDate(dtmDate)
On Error Resume Next
    WScript.Echo dtm:
    WMIDateStringToDate = CDate(Mid(dtmDate, 5, 2) & "/" & _
    Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) _
    & " " & Mid (dtmDate, 9, 2) & ":" & Mid(dtmDate, 11, 2) & ":" & Mid(dtmDate,13, 2))
End Function
 
If Wscript.Arguments.Named("u") <> "" And Wscript.Arguments.Named("p") <> "" Then
    boolAlternate = True
    strUser = WScript.Arguments.Named("u")
    strPassword = WScript.Arguments.Named("p")
'    WScript.Echo "Using alternate credentials..."
Else
    boolAlternate = False
'    WScript.Echo "Using current credentials..."
End If
 
If WScript.Arguments.Named("s") = "" Then
    arrComputers = Array(".")
Else
    arrComputers = Split(WScript.Arguments.Named("s"), ",")
End If
 
For Each strComputer In arrComputers
 
    If boolAlternate = True Then
        strNamespace = "root\cimv2"
        Set objWbemLocator = CreateObject("WbemScripting.SWbemLocator")
        Set objWMIService = objwbemLocator.ConnectServer(strComputer, strNamespace, strUser, strPassword)
        objWMIService.Security_.authenticationLevel = WbemAuthenticationLevelPktPrivacy
    Else
        Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
    End If
 
Wscript.Echo "<?xml version=" & Chr(34) & "1.0" & Chr(34) & "?>"
Wscript.Echo "<Inventory_1.0>"
    If Wscript.Arguments.Named("c") <> "" Then
        ' This splits the "/c:" argument by a comma, and goes through each
        arrSections = Split(Wscript.Arguments.Named("c"), ",")
        For Each strSection In arrSections
            Select Case Trim(LCase(strSection))
                Case "hd"
                    HD_Info
                Case "pc"
                    PC_Info
                Case "bios"
                    Bios_Info
                Case "vid"
                    Video_Info
                Case "mem"
                    Memory_Info
                Case "nic"
                    NIC_Info
                Case "cpu"
                    CPU_Info
                Case "hwerr"
                    HW_Err_Info
                Case "os"
                    OS_Info
                Case "av"
                    AV_Info
                Case "fw"
                    FW_Info
            End Select
        Next
    Else
'        This is where all tests are run
'        WScript.Echo "Running all sections..."
        HD_Info
        PC_Info
        Bios_Info
        Video_Info
        Memory_Info
        NIC_Info
        CPU_Info
        HW_Err_Info
        OS_Info
        AV_Info
        FW_Info
    End If
Next
'    Get Mapped Drive(s) Info
Sub HD_Info
On Error Resume Next
    Wscript.Echo "<Drives>"
    Set colItems = objWMIService.ExecQuery("Select * from Win32_LogicalDisk Where Description = 'Network Connection'")
    For Each objItem in colItems
        WScript.Echo    "<MD>"
        WScript.Echo  "<VolumeName>" & objItem.VolumeName & "</VolumeName>"
        WScript.Echo  "<Description>" & objItem.Description & "</Description>"
        WScript.Echo  "<Name>" & objItem.Name & "</Name>"
        WScript.Echo  "<DeviceID>" & objItem.DeviceID & "</DeviceID>"
        WScript.Echo  "<Size>" & objItem.Size & "</Size>"
        Wscript.Echo  "<FreeSpace>" & objItem.FreeSpace & "</FreeSpace>"
        Wscript.Echo  "<FileSystem>" & objItem.FileSystem & "</FileSystem>"
        WScript.Echo    "<ProviderName>" & objItem.ProviderName & "</ProviderName>"
        Wscript.Echo  "<VolumeSerialNumber>" & objItem.VolumeSerialNumber & "</VolumeSerialNumber>"
        WScript.Echo    "</MD>"
    Next
'    Get Harddrive(s) Info
    Set colItems = objWMIService.ExecQuery("Select * from Win32_LogicalDisk Where Description = 'Local Fixed Disk'")
    For Each objItem in colItems
        WScript.Echo    "<HD>"
        WScript.Echo  "<VolumeName>" & objItem.VolumeName & "</VolumeName>"
        WScript.Echo  "<Description>" & objItem.Description & "</Description>"
        WScript.Echo  "<Name>" & objItem.Name & "</Name>"
        WScript.Echo  "<DeviceID>" & objItem.DeviceID & "</DeviceID>"
        WScript.Echo  "<Size>" & objItem.Size & "</Size>"
        Wscript.Echo  "<FreeSpace>" & objItem.FreeSpace & "</FreeSpace>"
        Wscript.Echo  "<FileSystem>" & objItem.FileSystem & "</FileSystem>"
        Wscript.Echo  "<VolumeSerialNumber>" & objItem.VolumeSerialNumber & "</VolumeSerialNumber>"
        WScript.Echo    "</HD>"
    Next
    Wscript.Echo "</Drives>"
End Sub
'    Get Local Login Information
Sub PC_Info
On Error Resume Next
    Wscript.Echo "<PC_info>"
    Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)
    For Each objItem in colItems
        Wscript.Echo  "<Caption>" & objItem.Caption & "</Caption>"
        Wscript.Echo  "<CurrentTimeZone>" & objItem.CurrentTimeZone & "</CurrentTimeZone>"
        Wscript.Echo  "<Description>" & objItem.Description & "</Description>"
        Wscript.Echo  "<DomainRole>" & objItem.DomainRole & "</DomainRole>"
        Wscript.Echo  "<Manufacturer>" & objItem.Manufacturer & "</Manufacturer>"
        Wscript.Echo  "<Model>" & objItem.Model & "</Model>"
        Wscript.Echo  "<Name>" & objItem.Name & "</Name>"
        Wscript.Echo  "<Domain>" & objItem.Domain & "</Domain>"
        Wscript.Echo  "<UserName>" & objItem.UserName & "</UserName>"
    Next
    Wscript.Echo "</PC_info>"
End Sub
 
'    Get Bios info, includng Asset Tag, Bios Revision and Manufacturer
Sub Bios_Info
On Error Resume Next
    Set colItems = objWMIService.ExecQuery("Select * from Win32_BIOS",,48)
      Wscript.Echo "<BIOS>"
    For Each objItem in colItems
        Wscript.Echo  "<BuildNumber>" & objItem.BuildNumber & "</BuildNumber>"
        Wscript.Echo  "<ReleaseDate>" & WMIDateStringToDate(objItem.ReleaseDate) & "</ReleaseDate>"
        Wscript.Echo  "<Description>" & objItem.Description & "</Description>"
        Wscript.Echo  "<Manufacturer>" & objItem.Manufacturer & "</Manufacturer>"
        Wscript.Echo  "<Name>" & objItem.Name & "</Name>"
        Wscript.Echo  "<SerialNumber>" & objItem.SerialNumber & "</SerialNumber>"
        Wscript.Echo  "<Status>" & objItem.Status & "</Status>"
        Wscript.Echo  "<Version>" & objItem.Version & "</Version>"
    Next
   Wscript.Echo "</BIOS>"
End Sub
 
'    Get Screen Resolution, Refreash and Video Card info
Sub Video_Info
On Error Resume Next
    Wscript.Echo "<Video>"
    Set colItems = objWMIService.ExecQuery("Select * from Win32_DisplayControllerConfiguration",,48)
    For Each objItem in colItems
        Wscript.Echo "<Display>"
        Wscript.Echo  "<Description>" & objItem.Description & "</Description>"
        Wscript.Echo  "<Name>" & objItem.Name & "</Name>"
        Wscript.Echo  "<RefreshRate>" & objItem.RefreshRate & "</RefreshRate>"
        Wscript.Echo  "<VideoMode>" & objItem.VideoMode & "</VideoMode>"
        Wscript.Echo "</Display>"
    Next
    Wscript.Echo "</Video>"
End Sub
 
'    Get Memory Information
Sub Memory_Info
On Error Resume Next
    Wscript.Echo "<Memory>"
    Set colItems = objWMIService.ExecQuery("Select * from Win32_LogicalMemoryConfiguration",,48)
    For Each objItem in colItems
        Wscript.Echo  "<AvailableVirtualMemory>" & objItem.AvailableVirtualMemory & "</AvailableVirtualMemory>"
        Wscript.Echo  "<TotalPageFileSpace>" & objItem.TotalPageFileSpace & "</TotalPageFileSpace>"
        Wscript.Echo  "<TotalPhysicalMemory>" & objItem.TotalPhysicalMemory & "</TotalPhysicalMemory>"
        Wscript.Echo  "<TotalVirtualMemory>" & objItem.TotalVirtualMemory & "</TotalVirtualMemory>"
    Next
    Wscript.Echo "</Memory>"
End Sub
 
'    Get NIC information
Sub NIC_Info
On Error Resume Next
    Wscript.Echo "<Network>"
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * From Win32_NetworkAdapterConfiguration " & "Where IPEnabled = True")
        For Each objItem in colItems
        Wscript.Echo "<NIC>"
        ' Beginning of Adapter specific information
        Wscript.Echo "<Caption>" & objItem.Caption & "</Caption>"
        If Not IsNull(objItem.DNSDomainSuffixSearchOrder) Then
          Dim strDefaultIPGateway : strDefaultIPGateway = Join(objItem.DefaultIPGateway, ",")
          Wscript.Echo "<DefaultIPGateway>" & strDefaultIPGateway & "</DefaultIPGateway>"
        End If
        Wscript.Echo "<Description>" & objItem.Description & "</Description>"
        If Not IsNull(objItem.DNSDomainSuffixSearchOrder) Then
          Dim strDNSDomainSuffixSearchOrder : strDNSDomainSuffixSearchOrder = Join(objItem.DNSDomainSuffixSearchOrder, ",")
          Wscript.Echo "<DNSSrchOrd>" & strDNSDomainSuffixSearchOrder & "</DNSSrchOrd>"
        End If
       
        Wscript.Echo "<DHCPEnabled>" & objItem.DHCPEnabled & "</DHCPEnabled>"
        Wscript.Echo "<MACAddress>" & objItem.MACAddress & "</MACAddress>"
        Wscript.Echo "<WINSPrimaryServer>" & objItem.WINSPrimaryServer & "</WINSPrimaryServer>"
        Wscript.Echo "<WINSSecondaryServer>" & objItem.WINSSecondaryServer & "</WINSSecondaryServer>"
        ' Beginning IP Address Listing
        Wscript.Echo "<IPAddresses>"
        Dim i
        For i = 0 To UBound (objItem.IPAddress)
          Wscript.Echo "<IPAddress>" & objItem.IPAddress(i) & "</IPAddress>"
          Wscript.Echo "<IPSubnet>" & objItem.IPSubnet(i) & "</IPSubnet>"
        Next
        ' Writing End of IP Address Listing
        Wscript.Echo "</IPAddresses>"
        Next
        ' Writing End of NIC
        Wscript.Echo "</NIC>"
End Sub
 
'    Get CPU Information
Sub CPU_Info
On Error Resume Next
    Wscript.Echo "<Processors>"
    Set colItems = objWMIService.ExecQuery("Select * from Win32_Processor",,48)
    For Each objItem in colItems
        Wscript.Echo "<CPU>"
        Wscript.Echo  "<DeviceID>" & objItem.DeviceID & "</DeviceID>"
        Wscript.Echo  "<Caption>" & objItem.Caption & "</Caption>"
        Wscript.Echo  "<CurrentClockSpeed>" & objItem.CurrentClockSpeed & "</CurrentClockSpeed>"
        Wscript.Echo  "<Description>" & objItem.Description & "</Description>"
        Wscript.Echo  "<Family>" & objItem.Family & "</Family>"
        Wscript.Echo  "<LoadPercentage>" & objItem.LoadPercentage & "</LoadPercentage>"
        Wscript.Echo  "<Manufacturer>" & objItem.Manufacturer & "</Manufacturer>"
        Wscript.Echo  "<Name>" & objItem.Name & "</Name>"
        Wscript.Echo  "<Status>" & objItem.Status & "</Status>"
        Wscript.Echo  "<Version>" & objItem.Version & "</Version>"
        Wscript.Echo "</CPU>"
    Next
    Wscript.Echo "</Processors>"
End Sub
 
'    Show non-functioning Devices (yellow exclamation point, or red circle)
Sub HW_Err_Info
On Error Resume Next
    Wscript.Echo "<HW_Issues>"
    Set colItems = objWMIService.ExecQuery("Select * from Win32_PNPEntity Where ConfigManagerErrorCode <> 0")
    For Each objItem in colItems
        Wscript.Echo "<HW_ERR>"
        Wscript.Echo  "<Name>" & objItem.Name & "</Name>"
        Wscript.Echo  "<Description>" & objItem.Description & "</Description>"
        Wscript.Echo  "<DeviceID>" & objItem.DeviceID & "</DeviceID>"
        Wscript.Echo  "<Manufacturer>" & objItem.Manufacturer & "</Manufacturer>"
        Wscript.Echo "</HW_ERR>"
    Next
    Wscript.Echo "</HW_Issues>"
End Sub
 
Sub OS_Info
On Error Resume Next
Wscript.Echo "<OS_Info>"
            Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem",,48)
            For Each objItem in colItems
      WScript.Echo "<CountryCode>" & objItem.CountryCode & "</CountryCode>"
      WScript.Echo "<CSDVersion>" & objItem.CSDVersion & "</CSDVersion>"
      WScript.Echo "<CSName>" & objItem.CSName & "</CSName>"
      WScript.Echo "<CurrentTimeZone>" & objItem.CurrentTimeZone & "</CurrentTimeZone>"
      WScript.Echo "<DEP_32BitApps>" & objItem.DataExecutionPrevention_32BitApplications & "</DEP_32BitApps>"
      WScript.Echo "<DEP_Available>" & objItem.DataExecutionPrevention_Available & "</DEP_Available>"
      WScript.Echo "<DEP_Drivers>" & objItem.DataExecutionPrevention_Drivers & "</DEP_Drivers>"
      WScript.Echo "<DEP_SupportPolicy>" & objItem.DataExecutionPrevention_SupportPolicy & "</DEP_SupportPolicy>"
      WScript.Echo "<FreePhysicalMemory>" & objItem.FreePhysicalMemory & "</FreePhysicalMemory>"
      WScript.Echo "<FreeSpaceInPagingFiles>" & objItem.FreeSpaceInPagingFiles & "</FreeSpaceInPagingFiles>"
      WScript.Echo "<FreeVirtualMemory>" & objItem.FreeVirtualMemory & "</FreeVirtualMemory>"
      WScript.Echo "<InstallDate>" & WMIDateStringToDate(objItem.InstallDate) & "</InstallDate>"
      WScript.Echo "<LastBootUpTime>" & WMIDateStringToDate(objItem.LastBootUpTime) & "</LastBootUpTime>"
      WScript.Echo "<LocalDateTime>" & WMIDateStringToDate(objItem.LocalDateTime) & "</LocalDateTime>"
      WScript.Echo "<Locale>" & objItem.Locale & "</Locale>"
      WScript.Echo "<NumberOfProcesses>" & objItem.NumberOfProcesses & "</NumberOfProcesses>"
      WScript.Echo "<NumberOfUsers>" & objItem.NumberOfUsers & "</NumberOfUsers>"
      WScript.Echo "<Organization>" & objItem.Organization & "</Organization>"
      WScript.Echo "<OSLanguage>" & objItem.OSLanguage & "</OSLanguage>"
      WScript.Echo "<OSProductSuite>" & objItem.OSProductSuite & "</OSProductSuite>"
      WScript.Echo "<OSType>" & objItem.OSType & "</OSType>"
      WScript.Echo "<ProductType>" & objItem.ProductType & "</ProductType>"
      WScript.Echo "<RegisteredUser>" & objItem.RegisteredUser & "</RegisteredUser>"
      WScript.Echo "<SerialNumber>" & objItem.SerialNumber & "</SerialNumber>"
      WScript.Echo "<ServicePackMajorVersion>" & objItem.ServicePackMajorVersion & "</ServicePackMajorVersion>"
      WScript.Echo "<ServicePackMinorVersion>" & objItem.ServicePackMinorVersion & "</ServicePackMinorVersion>"
      WScript.Echo "<Status>" & objItem.Status & "</Status>"
      WScript.Echo "<TotalSwapSpaceSize>" & objItem.TotalSwapSpaceSize & "</TotalSwapSpaceSize>"
      WScript.Echo "<TotalVirtualMemorySize>" & objItem.TotalVirtualMemorySize & "</TotalVirtualMemorySize>"
      WScript.Echo "<TotalVisibleMemorySize>" & objItem.TotalVisibleMemorySize & "</TotalVisibleMemorySize>"
      WScript.Echo "<Version>" & objItem.Version & "</Version>"
Next
Wscript.Echo "</OS_Info>"
End Sub
 
Sub AV_Info
On Error Resume Next
Wscript.Echo "<AV_Info>"
Set oWMIAV = GetObject ("winmgmts:\\" & strComputer & "\root\SecurityCenter")
Set colItems = oWMIAV.ExecQuery("Select * from AntiVirusProduct",,48)
 
If Err = 0 Then
   For Each objAVProduct In colItems
     WScript.Echo "<CompanyName>" & objAVProduct.companyName & "</CompanyName>"
     WScript.Echo "<DisplayName>" & objAVProduct.displayName & "</DisplayName>"
     WScript.Echo "<OAUIMd5Hash>" & objAVProduct.enableOnAccessUIMd5Hash & "</OAUIMd5Hash>"
     WScript.Echo "<OAUIParameters>" & objAVProduct.enableOnAccessUIParameters & "</OAUIParameters>"
     WScript.Echo "<InstanceGuid>" & objAVProduct.instanceGuid & "</InstanceGuid>"
     WScript.Echo "<OASEnabled>" & objAVProduct.onAccessScanningEnabled & "</OASEnabled>"
     WScript.Echo "<PENOAUI>" & objAVProduct.pathToEnableOnAccessUI & "</PENOAUI>"
     WScript.Echo "<PUUI>" & objAVProduct.pathToUpdateUI & "</PUUI>"
     WScript.Echo "<Up2Date>" & objAVProduct.productUptoDate & "</Up2Date>"
     WScript.Echo "<UUIMd5Hash>" & objAVProduct.updateUIMd5Hash & "</UUIMd5Hash>"
     WScript.Echo "<UUIParameters>" & objAVProduct.updateUIParameters & "</UUIParameters>"
     WScript.Echo "<VersionNumber>" & objAVProduct.versionNumber & "</VersionNumber>"
   Next
    Else
      Err.Clear
      WScript.Echo "<Error>"
      WScript.Echo "<Message>Unable to connect to SecurityCenter class on " & strComputer & "</Message>"
      WScript.Echo "<ErrNumber>" & Err.Number & "</ErrNumber>"
      WScript.Echo "<ErrSource>" & Err.Source & "</ErrSource>"
      WScript.Echo "<ErrDescription>" & Err.Description & "</ErrDescription>"
      WScript.Echo "</Error>"
    End If
Wscript.Echo "</AV_Info>"
End Sub
 
Sub FW_Info
On Error Resume Next
Wscript.Echo "<FW_Info>"
Set oWMIFW = GetObject ("winmgmts:\\" & strComputer & "\root\SecurityCenter")
Set colItems = oWMIFW.ExecQuery("Select * from FirewallProduct",,48)
If Err = 0 Then
   For Each objFWProduct In colItems
     WScript.Echo "<CompanyName>" & objFWProduct.companyName & "</CompanyName>"
     WScript.Echo "<DisplayName>" & objFWProduct.displayName & "</DisplayName>"
     WScript.Echo "<EnableUIMd5Hash>" & objFWProduct.enableUIMd5Hash & "</EnableUIMd5Hash>"
     WScript.Echo "<EnableUIParameters>" & objFWProduct.enableUIParameters & "</EnableUIParameters>"
     WScript.Echo "<InstanceGuid>" & objFWProduct.instanceGuid & "</InstanceGuid>"
     WScript.Echo "<PathToEnableUI>" & objFWProduct.pathToEnableOnUI & "</PathToEnableUI>"
     WScript.Echo "<VersionNumber>" & objFWProduct.versionNumber & "</VersionNumber>"
   Next
    Else
      Err.Clear
      WScript.Echo "<Error>"
      WScript.Echo "<Message>Unable to connect to SecurityCenter class on " & strComputer & "</Message>"
      WScript.Echo "<ErrNumber>" & Err.Number & "</ErrNumber>"
      WScript.Echo "<ErrSource>" & Err.Source & "</ErrSource>"
      WScript.Echo "<ErrDescription>" & Err.Description & "</ErrDescription>"
      WScript.Echo "</Error>"
    End If
Wscript.Echo "</FW_Info>"
End Sub
 
    Wscript.Echo "</Inventory_1.0>"

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286:
287:
288:
289:
290:
291:
292:
293:
294:
295:
296:
297:
298:
299:
300:
301:
302:
303:
304:
305:
306:
307:
308:
309:
310:
311:
312:
313:
314:
315:
316:
317:
318:
319:
320:
321:
322:
323:
324:
325:
326:
327:
328:
329:
330:
331:
332:
333:
334:
335:
336:
337:
338:
339:
340:
341:
342:
343:
344:
345:
346:
347:
348:
349:
350:
351:
352:
353:
354:
355:
356:
357:
358:
359:
360:
361:
362:
363:
364:
365:
366:
367:

Select allOpen in new window

 

by: cxrPosted on 2009-06-09 at 04:22:22ID: 24579951

You can remove lines 6,7,8 from the script, and replace lines 14-16 with this:

  if (isset($_POST['hd'])) $par[] = "hd";
  if (isset($_POST['biod'])) $par[] = "bios";
  if (isset($_POST['mem'])) $par[] = "mem";
                                              
1:
2:
3:

Select allOpen in new window

 

by: richrumblePosted on 2009-06-09 at 05:17:09ID: 24580270

I think that will do it, looks good. I'm going to dress it up a bit and post the more finalized product.
-rich

<?PHP
if($_POST) {
  $fqdn = $_POST['fqdn'];
  $user = $_POST['user'];
  $pass = $_POST['pass'];
  if (empty($fqdn) || empty($user) || empty($pass)) {
    echo "Fields fqdn, user and pass are required";
    exit;
  }
  $par = array();
  if (isset($_POST['hd'])) $par[] = "hd";
  if (isset($_POST['bios'])) $par[] = "bios";
  if (isset($_POST['mem'])) $par[] = "mem";
  $txt = empty($par) ? '' : '/c:'.implode(',', $par);
  $output = shell_exec("cscript /nologo c:\scripto\inv.vbs /s:$fqdn  /u:$user /p:\"$pass\" $txt");
  echo "<pre>$output</pre>";
}
?>
<form method="post">
fqdn/ip: <input type="text" name="fqdn" /><br />
user: <input type="text" name="user" /><br />
pass: <input type="text" name="pass" /><br />
hd:  <input type="checkbox" name="hd" value="hd" /><br />
bios: <input type="checkbox" name="bios" value="bios" /><br />
mem: <input type="checkbox" name="mem" value="mem" /><br />
<input type="submit" value="Execute" />
</form>

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:

Select allOpen in new window

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...