ASP Forum
servervariables in WSH like ASP
arrowgance | Posted 3:07am 12. March 2008 Server Time |

Hi can I imitate the server variable in vbs?

like in ASP I can use

         dim server_nameA1,script_nameA1,qs_,generaterss,generatenew,RM,RY
         server_nameA1 = lcase(trim(Request.ServerVariables("SERVER_NAME")))
         script_nameA1 = lcase(trim(Request.ServerVariables("SCRIPT_NAME")))

         server_ = "http://domain1/"
         if instr(server_nameA1,"domain2")>0 OR instr(server_nameA1,"dom2")>0 OR instr(script_nameA1,"do2")>0 then server_ = "http://domain2/"
         if instr(server_nameA1,"domain3")>0 then server_ = "http://domain3/"

So that I can run the asp or whatever no matter where domains, servers they are or wherever I port my ASP code?  That's fine with ASP but with windows scripting host I cannot find a solution any help?

'my WSH saved as myfile.VBS
-------------

         dim server_nameA1,script_nameA1,qs_,generaterss,generatenew,RM,RY
         server_nameA1 = lcase(trim(Request.ServerVariables("SERVER_NAME")))
         script_nameA1 = lcase(trim(Request.ServerVariables("SCRIPT_NAME")))

         server_ = "http://domain1/"
         if instr(server_nameA1,"domain2")>0 OR instr(server_nameA1,"dom2")>0 OR instr(script_nameA1,"do2")>0 then server_ = "http://domain2/"
         if instr(server_nameA1,"domain3")>0 then server_ = "http://domain3/"

'the above servervariable codes
'does not work on
'WSH, myfile.vbs


  use_url = server_
  sURL = use_url & "myfilewhatever.asp?"

'WScript.TimeOut = 500
oXMLHttp.open "GET", sURL, false
oXMLHttp.send()

'if oXMLHttp.status = 200 Then
' Retrieve enter HTML response
'MsgBox oXMLHttp.ResponseText
'else
' Failed
'end if

Thankx with a lot of pretty please on top :))
mp3cdman | Posted 9:03am 20. March 2008 Server Time |

try something like this

<%
    Set Loc = createobject("WBEMScripting.SWBEMLocator")
    Set nms = Loc.ConnectServer()
    WQL = "SELECT CSName FROM Win32_OperatingSystem"
    Set cs = nms.ExecQuery(WQL, "WQL", 48)
    For Each pc In cs
        Response.Write pc.CSName
    Next
    set cs = nothing: set nms = nothing: set loc = nothing
%>


mp3cdman...


Reply to Post servervariables in WSH like ASP



Back to Forum Page