Solved

What is wrong with my environment variable?!

Posted on 2013-10-25
9
342 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
 
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This is an addendum to the following article: Acitve Directory based Outlook Signature (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_24950055.html) The script is fine, and works in normal client-server domains…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

705 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now