Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run .vbs file via ASP

Status
Not open for further replies.

LilProgrammerGirl

Programmer
Jun 24, 2004
81
US
Hi all,
Essentially, I am trying to run a .vbs script on the server that will pass the user's nt login name to my asp page and display it on the screen. Right now, I use the include tag and it is literally just printing the code on my screen.

Here is the contents of my .vbs file:
Code:
Function ShowInfo
DIM strComputer

Set objNetwork = CreateObject("WScript.Network")
strComputer = objNetwork.ComputerName

Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") 
Set colComputer = objWMIService.ExecQuery _
    ("Select * from Win32_ComputerSystem")
 
For Each objComputer in colComputer
    wscript.echo "User Name: " & objComputer.UserName
Next

End Function

The contents of my asp page:
Code:
<% Response.Buffer = True %>
<html>
<head>
<title>Call Center Work Order Accuracy</title>
</head>
<BODY>
<!--#include file="showinfo.vbs" -->
<%
Response.Write showinfo()
%>
</body>
</html>

Does anyone have a clue as to what I am doing wrong?

Thanks much!
Hailey
 
Try to move the include line to top of page and then call the ShowInfo in Body onLoad.
 
Won't the LOGON_USER be a better choice here, or am I missing something?

Dim LOGON_USER
LOGON_USER = Request.ServerVariables("LOGON_USER")
 
That just displays the code in my browser when I run it..

JSpicolli,
Yes, I would love to use the LOGON_USER server variable, however, my IIS is set up to allow anonymous access and I set up an account used for anonymous access - using that same account to allow my site to query my SQL Server. If I change it to Integrated Windows authentication.. my queries won't work. Do you know a workaround for that??

Thanks,
Hailey
 
What I had to do was setup a user on my SQL server and set permissions for this user to run queries, update, etc. then my ADO connection strings look like this (it's an include file)

Code:
<%
	sProv = "Provider=SQLOLEDB.1;User ID=IE_User;Password=XXXXXXX;Initial Catalog=XXXXXXXX;Data Source=XXXXXXX"
	Set Conn = Server.CreateObject("ADODB.Connection")
	Set RS = Server.CreateObject("ADODB.Recordset")
	Conn.Open sProv
%>

I did this because our IIS server allowed anon connections and SQL didn't. Hope this helps
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top