?
Solved

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

Posted on 2003-03-05
16
Medium Priority
?
2,109 Views
Last Modified: 2007-12-19
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
Comment
Question by:swinslow
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 5
  • 3
  • +1
16 Comments
 
LVL 4

Expert Comment

by:CRagsdell
ID: 8076983
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
 

Expert Comment

by:KasKooye
ID: 8078202
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
 
LVL 4

Expert Comment

by:iozturk
ID: 8079170
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
Use Filtering Commands to Process Files in Linux

Learn how to manipulate data with the help of various filtering commands such as `cat`, `fmt`, `pr`, and others in Linux.

 
LVL 4

Author Comment

by:swinslow
ID: 8081961
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
 
LVL 4

Author Comment

by:swinslow
ID: 8082217
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
 
LVL 4

Author Comment

by:swinslow
ID: 8082630
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
 
LVL 4

Expert Comment

by:iozturk
ID: 8086571
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
 

Accepted Solution

by:
KasKooye earned 984 total points
ID: 8086653
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
 
LVL 4

Expert Comment

by:iozturk
ID: 8086694
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
 
LVL 4

Expert Comment

by:iozturk
ID: 8091502
Hey, I gave the answer but you gave points to another :(
0
 
LVL 4

Author Comment

by:swinslow
ID: 8091573
iozturk  - The script you have is server side. It will read the settings on the server not the clients computer.
0
 
LVL 4

Expert Comment

by:iozturk
ID: 8091761
Hey, I gave the answer but you gave points to another :(
0
 
LVL 4

Expert Comment

by:iozturk
ID: 8091775
No, read KasKooye's answer he says "as iozturk told u", and just one up answer form him/her.
0
 
LVL 4

Expert Comment

by:iozturk
ID: 8091779
This is actually a joke points not important we are sharing our knowledge :)
0
 

Expert Comment

by:KasKooye
ID: 8101357
Cool down guys !
If swinslow agrees, I'm ok to share my points with iozturk.

Have a nice day !
   J. Philippe
0
 
LVL 4

Author Comment

by:swinslow
ID: 8104158
Thats fine with me.
0

Featured Post

WordPress Tutorial 4: Recommended Plugins

Now that you have WordPress installed, understand the interface, and know how to install new parts, let’s take a look at our recommended plugins.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
When the s#!t hits the fan, you don’t have time to look up who’s on call, draft emails, call collaborators, or send text messages. An instant chat window is definitely the way to go, especially one like HipChat. HipChat is a true business app. An…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question