Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Using a VBS within ASP Page

Posted on 2003-11-07
11
Medium Priority
?
390 Views
Last Modified: 2008-02-01
Hi All - What Im trying to do, is use this VBS which I converted to use within VB, to work within ASP so I can allow people to change the state of the Messenger Service via the browser but I don't know if it can be done... Any help would be great!

Set wbemservices = GetObject("winmgmts:\\.")
Set wbemObject = wbemservices.Get("Win32_Service.Name='Messenger'")
Wscript.echo "Display Name: " & wbemObject.DisplayName & vbCrlf _
     & vbTab & "State: " & wbemObject.State & vbCrlf _
     & vbTab & "StartMode: " & wbemObject.StartMode & vbCrlf _

Select Case wbemObject.StartMode
     Case "Boot"
     Case "System"
     Case "Auto"
          Wscript.Echo "Auto"
          wbemObject.ChangeStartMode "Manual"
     Case "Manual"
     Case "Disabled"
End Select

Select Case wbemObject.State
     Case "Stopped"
     Case "Start Pending"
     Case "Stop Pending"
     Case "Running"
          Wscript.Echo "Running"
     Case "Continue Pending"
     Case "Pause Pending"
     Case "Paused"
     Case "Unknown"
End Select
0
Comment
Question by:jilamints
  • 5
  • 4
11 Comments
 
LVL 21

Expert Comment

by:ap_sajith
ID: 9706252
I cant get the code to work on my side.. but i have converted the code to proper vbscript syntax... so you could give this a try...'

<Script language=vbscript>
Set wbemservices = CreateObject("winmgmts:\\.")
Set wbemObject = wbemservices.Get("Win32_Service.Name='Messenger'")
Wscript.echo "Display Name: " & wbemObject.DisplayName & vbCrlf _
    & vbTab & "State: " & wbemObject.State & vbCrlf _
     & vbTab & "StartMode: " & wbemObject.StartMode & vbCrlf _

Select Case wbemObject.StartMode
     Case "Boot"
    Case "System"
    Case "Auto"
         Wscript.Echo "Auto"
         wbemObject.ChangeStartMode "Manual"
    Case "Manual"
     Case "Disabled"
End Select

Select Case wbemObject.State
    Case "Stopped"
    Case "Start Pending"
    Case "Stop Pending"
    Case "Running"
         Wscript.Echo "Running"
    Case "Continue Pending"
    Case "Pause Pending"
    Case "Paused"
    Case "Unknown"
End Select
</script>

Cheers!!
0
 

Author Comment

by:jilamints
ID: 9706412
I get an error when I try and run it:

ActiveX compon
0
 

Author Comment

by:jilamints
ID: 9706413
Sorry: Again...

ActiveX component can't create object 'winmgmts:\\.'

0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 21

Expert Comment

by:ap_sajith
ID: 9706693
I got the same error. Since i dont have that component installed on my pc, its giving the error. What does the winmgmts component do?. Is it supposed to run client side or server side?. If it is supposed to run client side, make sure that you have the component installed in the client.

If it is server side, the code is going to be slightly differrent.

Cheers!!
0
 

Author Comment

by:jilamints
ID: 9708284
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnclinic/html/scripting08132002.asp

I want this to run on the client side so the user can check the status of the server, then take a certain course of action ?
0
 
LVL 21

Expert Comment

by:ap_sajith
ID: 9708943
http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=6430F853-1120-48DB-8CC5-F2ABDC3ED314

Read the system requirements and make sure that you have WMI v1.5 installed in the PC from which you are executing the code.

Cheers!!
0
 

Author Comment

by:jilamints
ID: 9708971
Well I'm using Windows 2000 and the server is W2K Adv Server - Now after installing this, I still have the same problems and, my VB version of this, which is basically exactly the same, works perfect... So I don't see how I can get around my little problem ?

Do I make up some ActiveX thing for people to download or what ?
0
 
LVL 21

Accepted Solution

by:
ap_sajith earned 1000 total points
ID: 9709022
Why dont you use this piece of server side code to check for server availability....

<%

function isServerAvailable(sURL)
Dim objXMLHTTP                  'Holds the XML HTTP Object

'Create an XML object to query the remote whois server
Set objXMLHTTP = Server.CreateObject("Microsoft.XMLHTTP")

'Alternative XML HTTP component, for version 3.0 of XMLHTTP
'Set objXMLHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP")

'Open a connection to the remote whois server
objXMLHTTP.Open "GET", sURL, False

'Send the request and return the data
objXMLHTTP.Send

If objXMLHTTP.Status=200 Then ' ** IF PAGE HAS BEEN RETRIEVED THEN **
      isServerAvailable=True
Else
      isServerAvailable=False
End If
End Function

response.write isServerAvailable("http://site/test.asp")
%>

Cheers!!
0
 
LVL 21

Expert Comment

by:ap_sajith
ID: 10243488
Hi,
Any Updates?. Do you need any further assistance with this?. Please close this question if no further assistance is needed.
If you need help closing this question, please refer to http://oldlook.experts-exchange.com/help/closing.jsp on how to close a question.

Cheers!!
0
 
LVL 7

Expert Comment

by:vnvk
ID: 11962180
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I will leave the following recommendation for this question in the Cleanup topic area:
    Accept: ap_sajith {http:#9709022}

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

vnvk
EE Cleanup Volunteer
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

927 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