Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2113
  • Last Modified:

VBScript - Not getting any output (Wscript.shell and Wscript.Network)

I am not getting any output to the screen with the following script. I am not sure what I have done wrong. I am use to doing things server side instead of client side.

Thanx,
Soren


  <html>
  <head>
  </head>
  <body>

     
  <script type="text/vbscript">

    Set objReg = Createobject("Wscript.shell")

        document.write("<div> InstallDate : " & objReg.regread("HKEY_LOCAL_MACHINE\Software\Adobe\Adobe Acrobat\5.0\installer\InstallDate") & "</div>")
        document.write("<div> InstallTime : " & objReg.regread("HKEY_LOCAL_MACHINE\Software\Adobe\Adobe Acrobat\5.0\installer\InstallTime") & "</div>")

    set objReg = Nothing

   Set ObjNet = CreateObject("Wscript.Network")
       
        document.write("<div>Domain :" & ObjNet.UserDomain & "</div>")
        document.write("<div>ComputerName :" & ObjNet.ComputerName & "</div>")
        document.write("<div>UserName " & ObjNet.UserName & "</div>")

    Set ObjNet = Nothing


   </script>
   
   </body>
   </html>

0
swinslow
Asked:
swinslow
  • 7
  • 5
  • 3
  • +1
1 Solution
 
CRagsdellCommented:
Are you sure you are getting a completed page?

I get the dreaded exclamation point in the yellow triangle symbol that shows the script didn't run properly. My server didn't support Createobject("Wscript.shell").

The error message is "ActiveX component can't create object : 'Wscript.shell'

I think you want to work with WshShell.RegRead and WshNetwork.

Here are links:

http://www.devguru.com/technologies/wsh/quickref/wshshell.html

http://www.devguru.com/technologies/wsh/quickref/wshnetwork.html

CR
0
 
KasKooyeCommented:
Your code is perfectly right. The only fact is that....

..this will work only when the page is not seen thru a web server !

Registry orperation, and creation of shell components are available only when used in "local mode" or "file mode" (that's the way Web folders are working when you set the explorer option to "dispaly as web page")

For security reaseons, remote activation of activeX components are not allowed using a web server.
This the explanation of your message "cannot cre
0
 
iozturkCommented:
If you want to run the script in server side then make it asp

<%
   Set objReg = server.Createobject("Wscript.shell")

       response.write("<div> InstallDate : " & objReg.regread("HKEY_LOCAL_MACHINE\Software\Adobe\Adobe Acrobat\5.0\installer\InstallDate") & "</div>")
       response.write("<div> InstallTime : " & objReg.regread("HKEY_LOCAL_MACHINE\Software\Adobe\Adobe Acrobat\5.0\installer\InstallTime") & "</div>")

   set objReg = Nothing

  Set ObjNet = server.CreateObject("Wscript.Network")
       
       response.write("<div>Domain :" & ObjNet.UserDomain & "</div>")
       response.write("<div>ComputerName :" & ObjNet.ComputerName & "</div>")
       response.write("<div>UserName " & ObjNet.UserName & "</div>")

   Set ObjNet = Nothing


%>
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
swinslowAuthor Commented:
iozturk -
Yes, I can get it to run serverside using ASP. But I need it to run client side.

KasKooye -
I tried opening it locally (not through the web server) on a Win 2k computer, a Win XP computer and a Win 98 computer. All I get is a blank screen.

To All -
I am increasing the points to 328 points. Who ever can get me a script that will work will get the points.
0
 
swinslowAuthor Commented:
iozturk -
Yes, I can get it to run serverside using ASP. But I need it to run client side.

KasKooye -
I tried opening it locally (not through the web server) on a Win 2k computer, a Win XP computer and a Win 98 computer. All I get is a blank screen.

To All -
I am increasing the points to 328 points. Who ever can get me a script that will work will get the points.
0
 
swinslowAuthor Commented:
iozturk -
Yes, I can get it to run serverside using ASP. But I need it to run client side.

KasKooye -
I tried opening it locally (not through the web server) on a Win 2k computer, a Win XP computer and a Win 98 computer. All I get is a blank screen.

To All -
I am increasing the points to 328 points. Who ever can get me a script that will work will get the points.
0
 
iozturkCommented:
In order to run the script in client side client browser security setting must be

For all ActiveX controls & scripts -> enable

Otherwise you cannot run it in script you should try it with activeX control.
0
 
KasKooyeCommented:
As iozturk told u, you must enable ActiveX scripting within IE options.
I ran your script successfuly on my PC (Win98 / IE6).
Here's the output :

InstallDate : 8-14-2002
InstallTime : 17:40:01
Domain :
ComputerName :NOSTROMO
UserName M232xxx
0
 
iozturkCommented:
Or you may do it with request.server variables
e.g.

<%
Response.Write Request.ServerVariables("REMOTE_HOST")
Response.Write Request.ServerVariables("REMOTE_USER")
Response.Write Request.ServerVariables("SERVER_SOFTWARE")
Response.Write Request.ServerVariables("LOGON_USER")
%>

Some lines does not give any result. But nothing to do with Client software version(acrobat version).
0
 
iozturkCommented:
Hey, I gave the answer but you gave points to another :(
0
 
swinslowAuthor Commented:
iozturk  - The script you have is server side. It will read the settings on the server not the clients computer.
0
 
iozturkCommented:
Hey, I gave the answer but you gave points to another :(
0
 
iozturkCommented:
No, read KasKooye's answer he says "as iozturk told u", and just one up answer form him/her.
0
 
iozturkCommented:
This is actually a joke points not important we are sharing our knowledge :)
0
 
KasKooyeCommented:
Cool down guys !
If swinslow agrees, I'm ok to share my points with iozturk.

Have a nice day !
   J. Philippe
0
 
swinslowAuthor Commented:
Thats fine with me.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 7
  • 5
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now