Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


vbscript read environment variable for if statment

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,2321
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> vbscript read environment variable for if statment
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 vbscript read environment variable for if statment - 3/13/2005 10:16:54 PM   
  battousai

 

Posts: 1
Score: 0
Joined: 3/13/2005
From:
Status: offline
hi,

i'm trying to write a script to map a printer when a user logs on depending on a environment variable called location with a value of room1

-
if ("%location%" = room1) then
Set WshNetwork = WScript.CreateObject("WScript.Network")
PrinterPath = "\\printsrv\room1printer"
WshNetwork.AddWindowsPrinterConnection PrinterPath
else
end if
-

but this doesn't map any printers but doen't give me any error information to work with,

any help would be great...
 
 
Post #: 1
 
 Re: vbscript read environment variable for if statment - 3/13/2005 11:02:03 PM   
  Zifter


Posts: 318
Score: 0
Joined: 1/5/2005
From: Belgium
Status: offline
To retrieve a value of an environment variable, you'll need something like this:
      HTH

(in reply to battousai)
 
 
Post #: 2
 
 Re: vbscript read environment variable for if statment - 3/14/2005 3:50:27 AM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
Like Zifter suggested, you can use the SHELL object.

=============================================================================
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set sh = WScript.CreateObject("WScript.Shell")

location = sh.ExpandEnvironmentStrings("%location%")

if (location = "room1") then
PrinterPath = "\\printsrv\room1printer"
WshNetwork.AddWindowsPrinterConnection PrinterPath
end if

(in reply to battousai)
 
 
Post #: 3
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> vbscript read environment variable for if statment Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts