Page 1 of 1

How to execute vb script through php?

Posted: Thu Jan 21, 2010 10:36 am
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>

Re: How to execute vb script through php?

Posted: Thu Jan 21, 2010 11:48 am
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']));
}
 
?>

Re: How to execute vb script through php?

Posted: Thu Jan 21, 2010 12:18 pm
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

Re: How to execute vb script through php?

Posted: Thu Jan 21, 2010 12:32 pm
by AbraCadaver
Sorry... I only know a little about vbscript and really nothing about using it in a browser.