?
Solved

What is wrong with my environment variable?!

Posted on 2013-10-25
9
Medium Priority
?
351 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Recently I finished a vbscript that I thought I'd share.  It uses a text file with a list of server names to loop through and get various status reports, then writes them all into an Excel file.  Originally it was put together for our Altiris server…
When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses
Course of the Month14 days, 6 hours left to enroll

809 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