Laboratory/Develop

VBScript Printing Enviroment Vars

theking 2008. 2. 21. 22:30

Subject: VBScript Printing Enviroment Vars

Original Message
Name:Stuart Crawshaw
Date:February 04, 2004 at 09:47:40 Pacific
Subject:VBScript Printing Enviroment Vars
OS:Windows XP
CPU/Ram:/
Comment:
I would like to know if there is a peice of code (VBScript) that will call an enviroment variable and print it into a webpage. eg

I want to use the %USERNAME% variable on a page like this:

Welcome + %USERNAME% To my website


thanks in advance
Stuart


Report Offensive Message For Removal

Response Number 1
Name: Infinite Recursion
Date:February 05, 2004 at 21:41:18 Pacific
Subject:VBScript Printing Enviroment Vars
Reply:
In VB .NET (maybe in VB6 and VBScript) you can use the Environ() to do this.

For example:

Msgbox("Username: " & Environ(USERNAME))

IR


Report Offensive Follow Up For Removal

Response Number 2
Name:philip
Date:February 06, 2004 at 12:33:56 Pacific
Subject:VBScript Printing Enviroment Vars
Reply:
set shell = createObject("wscript.shell")
set env = shell.environment("system")
msgbox env("OS")

This should be it, but "username" returns null, I don't know why.


Report Offensive Follow Up For Removal

Response Number 3
Name: philipl
Date:February 06, 2004 at 12:45:54 Pacific
Subject:VBScript Printing Enviroment Vars
Reply:
Whoops...sorry about the last code....

To actually get the username you have to use the network object.

set network = createObject("wscript.network")
username = network.username


Report Offensive Follow Up For Removal
출처 :http://www.computing.net/programming/wwwboard/forum/9426.html