Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 557
  • Last Modified:

VBScript does not work in Global.asa

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
dubisteam
Asked:
dubisteam
  • 6
  • 3
2 Solutions
 
SquareHeadCommented:
Can you post your code?
0
 
dubisteamAuthor Commented:
-------------------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
 
SquareHeadCommented:
Maybe this:

set Shell = WScript.createobject("wscript.shell")
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
dubisteamAuthor Commented:
An error appeared saying "Object required: 'WScript' ". Any Ideas ??
0
 
SquareHeadCommented:
hmm, not yet. I was referncing this page: http://www.winguides.com/scripting/reference.php?id=109
0
 
SquareHeadCommented:
Maybe server.createobject...
0
 
dubisteamAuthor Commented:
Yeah, tried server.createobject and it worked but script doesnt seem to be working. Session("user_id") is blank. Don't know why
0
 
SquareHeadCommented:
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
 
SquareHeadCommented:
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
 
joeposter649Commented:
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

  • 6
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now