Solved

VBScript does not work in Global.asa

Posted on 2006-11-29
10
553 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
[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
  • 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
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 

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
 
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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Suggested Solutions

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

733 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