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
Solved

What is wrong with my environment variable?!

Posted on 2013-10-25
9
346 Views
Last Modified: 2013-10-25
I have this line in my login script:
Set WshShell = Wscript.CreateObject("Wscript.Shell")
Set WshSysEnv = WshShell.Environment("USER")
WshSysEnv.item("GP_OFFICE") = "CHICAGO"

I open a command prompt and type set.... I see this variable.

When I open autocad and type (getenv "GP_OFFICE") and get nil.  I can use the system command (getenv) on other environment variables and get their values.

I've even modified this line
Set WshSysEnv = WshShell.Environment("USER")
to read
Set WshSysEnv = WshShell.Environment("SYSTEM")
with the same results.

hmmmmmmmmm.....
help
0
Comment
Question by:gpchicago08
  • 5
  • 4
9 Comments
 
LVL 19

Expert Comment

by:Ken Butters
ID: 39601162
try this format ?

wSystemEnv("<Name>") = "<Value>"

in your example:
wSystemEnv("GP_OFFICE") = "CHICAGO"
0
 

Author Comment

by:gpchicago08
ID: 39601189
This change didn't solve the problem.  It changed the environment variable just like before, just didn't make it available in my program.
0
 

Author Comment

by:gpchicago08
ID: 39601216
I run this bat file in a command prompt and get the correct value.

echo  The GP_OFFICE VARIABLE IS: %GP_OFFICE%
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 19

Expert Comment

by:Ken Butters
ID: 39601278
I was researching a little on AutoCad... I am not familiar with Autocad... but I've seen indications that you have a limited list of environment variables that are exposed to Autocad... not necessarily any System Variable that you define.

My line of reasoning :
Since you type 'set' at the command line and see the variable being set correctly... that would indicate that the variable is set up properly...

that leaves us with just the problem of reading it in Autocad.
0
 
LVL 19

Accepted Solution

by:
Ken Butters earned 500 total points
ID: 39601299
looks like Autocad had a command SetEnv...

Can you issue the following Command: (setenv "GP_OFFICE" "CHICAGO"), and then see if you can use getenv to retrieve the value?

I am wondering if there is a difference between the  autocad environment variables and window environment variables.
0
 

Author Comment

by:gpchicago08
ID: 39601457
yes.  (setenv) does set and then I get the value.  However, I need to set this value way before even opening autocad.
0
 

Author Comment

by:gpchicago08
ID: 39601579
Well, my original code was fine.  I just needed to dig at it a little deeper from within AutoCAD

auotcad code:
(vl-registry-read "HKEY_CURRENT_USER\\Environment" "GP_OFFICE")

Open in new window

0
 

Author Closing Comment

by:gpchicago08
ID: 39601584
points just because you cared enough to help.... snif
0
 
LVL 19

Expert Comment

by:Ken Butters
ID: 39601645
Nice!  

I did find out that AutoCAD stores things in different folders than windows:

so the additional parms you found must be enough to look "In the right place" !!!

Windows USER environment Variables are stored here
HKEY_CURRENT_USER\Environment\

Windws System environment variables are stored here
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\

Autocad :
HKEY_CURRENT_USER\Software\Autodesk\AutoCAD\...your version .... \Profiles\<< Profile Name >>\General
HKEY_CURRENT_USER\Software\Autodesk\AutoCAD\...your version ....\FixedProfile
HKEY_CURRENT_USER\Software\Autodesk\AutoCAD\...your version ....\Profiles\AutoCAD\General
HKEY_CURRENT_USER\Software\Autodesk\AutoCAD\...your version ....\Variables
HKEY_LOCAL_MACHINE\SOFTWARE\Autodesk\AutoCAD\...your version ....\Variables
HKEY_CURRENT_USER\Software\Autodesk\AutoCAD\...your version ....\Profiles\AutoCAD\Variables
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
File download script VBSCRIPT fail on download PPT files 2 59
Modifying Powershell and WMI to obtain disk, cpu, mem & IP data ? 5 69
VBScript Issues 8 40
Attention Please 10 48
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

808 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