?
Solved

What is wrong with my environment variable?!

Posted on 2013-10-25
9
Medium Priority
?
349 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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 2000 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

Technology Partners: 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!

Question has a verified solution.

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

In this article we want to have a look at the directory attributes which are used by Microsoft to store the so called Security Identifiers (SID). These SIDs plays an important role in delegating and granting permissions and in authentication of trus…
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…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

770 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