Solved

VBScript does not work in Global.asa

Posted on 2006-11-29
10
543 Views
Last Modified: 2007-12-19
Hi All,

I have a VBScript that retrieves user name of person logged into computer. This code works when embedded in a asp page but doesnt seem to work when i put the code into a Global.asa. Has anyone any suggestions ??
0
Comment
Question by:dubisteam
  • 6
  • 3
10 Comments
 
LVL 18

Expert Comment

by:SquareHead
ID: 18036617
Can you post your code?
0
 

Author Comment

by:dubisteam
ID: 18036953
-------------------Global.asa--------------------------------------------------------------------------------------
<SCRIPT LANGUAGE="VBScript" RUNAT="Server">

Sub Application_OnStart

End Sub

Sub Application_OnEnd


End Sub



Sub Session_OnStart

Session("Test") = Now()

Dim Shell
Dim strUser
set Shell = createobject("wscript.shell")
set env = shell.environment("process")
Session("user_id") = env("username")

End Sub


Sub Session_OnEnd


End Sub

</SCRIPT>
0
 
LVL 18

Expert Comment

by:SquareHead
ID: 18037069
Maybe this:

set Shell = WScript.createobject("wscript.shell")
0
 

Author Comment

by:dubisteam
ID: 18037447
An error appeared saying "Object required: 'WScript' ". Any Ideas ??
0
 
LVL 18

Expert Comment

by:SquareHead
ID: 18037475
hmm, not yet. I was referncing this page: http://www.winguides.com/scripting/reference.php?id=109
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 18

Expert Comment

by:SquareHead
ID: 18037482
Maybe server.createobject...
0
 

Author Comment

by:dubisteam
ID: 18037520
Yeah, tried server.createobject and it worked but script doesnt seem to be working. Session("user_id") is blank. Don't know why
0
 
LVL 18

Expert Comment

by:SquareHead
ID: 18037552
It may be because you are looking for that session var when the session runs the first time... Before you've set that var...
0
 
LVL 18

Assisted Solution

by:SquareHead
SquareHead earned 60 total points
ID: 18037599
Oh I see what you mean, disregard my last comment. You mean the env("username") is empty I guess, and not setting a value in the session var...
0
 
LVL 15

Accepted Solution

by:
joeposter649 earned 65 total points
ID: 18039021
You're trying to get an environment variable called username on the web server and assign it to a session varibable called user_id?  Wouldn't every user get the same user_id?
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

708 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now