How to execute vb script through php?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dimxasnewfrozen
Forum Commoner
Posts: 84
Joined: Fri Oct 30, 2009 1:21 pm

How to execute vb script through php?

Post by dimxasnewfrozen »

I'm trying to get the current logged in user of the machine. The vbscript gets the right information but how can I execute this in php?

Code: Select all

<html><body>
<script language="vbscript">
Dim objNet
On Error Resume Next 
Set objNet = CreateObject("WScript.NetWork") 
If  Err.Number <> 0 Then
 
    MsgBox "Don't be Shy." & vbCRLF &_
               "Do not press ""No"" If your browser warns you."
    Document.Location = "test.php"    
 
End if
    
Dim strInfo
strInfo = "User Name is     " & objNet.UserName & vbCRLF & _
          "Computer Name is " & objNet.ComputerName & vbCRLF & _
          "Domain Name is   " & objNet.UserDomain
MsgBox strInfo
    
Set objNet = Nothing
</script>
</body>
 
<?php
    // DISPLAY VB SCRIPT CONTENTS
?>
 
 </html>
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: How to execute vb script through php?

Post by AbraCadaver »

You can't get the var in the same page load because the PHP is executed on the server and the result is sent to the browser where the vb script is executed. Something like this may work.

After data has been gathered and concatenated into a string by vb script, redirect to this same page with the data in the query string as the data var:

Code: Select all

Dim strInfo
strInfo = "User Name is     " & objNet.UserName & vbCRLF & _
          "Computer Name is " & objNet.ComputerName & vbCRLF & _
          "Domain Name is   " & objNet.UserDomain
 
Document.Location = "current_page.php?data=" & escape(strInfo)
Then for the PHP you would display the GET var data:

Code: Select all

<?php
 
if(isset($_GET['data'])) {
    echo nl2br(htmlentities($_GET['data']));
}
 
?>
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
dimxasnewfrozen
Forum Commoner
Posts: 84
Joined: Fri Oct 30, 2009 1:21 pm

Re: How to execute vb script through php?

Post by dimxasnewfrozen »

That makes perfect sense but for some reason the vbscript isn't assigning the variable.

IE is giving me the error of "ActiveX component can't create Wscript.network"

I understand this is a vb issue at this point but perhaps it's a simple fix.


Thank you
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: How to execute vb script through php?

Post by AbraCadaver »

Sorry... I only know a little about vbscript and really nothing about using it in a browser.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Post Reply