Solved

What is wrong with my environment variable?!

Posted on 2013-10-25
9
348 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
[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
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Script to copy or move mouse-selected collection of files plus targets referenced by shortcuts (.lnk) The purpose of this article is to help illuminate the real challenges and options available (where they may exist) for utilizing simple scriptin…
Well hello again!  Glad to see you've made it this far without giving up.  In this, the fourth installment of my popular series, I'm going to cover functions and subroutines, what they are, and why they are useful.  Just in case you stumbled onto th…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

724 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