Results 1 to 8 of 8

Thread: Setting Environment Variable in login script doesn't show up in AutoCAD 2014!!! ARGH!!!

  1. #1
    AUGI Addict bowlingbrad's Avatar
    Join Date
    2003-11
    Location
    Chicago
    Posts
    1,233
    Login to Give a bone
    0

    Default Setting Environment Variable in login script doesn't show up in AutoCAD 2014!!! ARGH!!!

    I have this line in my login script:

    Code:
    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.

    I open autocad and type (getenv "GP_OFFICE") and get nil.

    hmmmmmmmmm.....

    help?
    Last edited by BlackBox; 2013-10-25 at 05:44 PM. Reason: Please use [CODE] Tags

  2. #2
    AUGI Addict bowlingbrad's Avatar
    Join Date
    2003-11
    Location
    Chicago
    Posts
    1,233
    Login to Give a bone
    0

    Default Re: Setting Environment Variable in login script doesn't show up in AutoCAD 2014!!! ARGH!!!

    I've even modified this line

    Code:
    Set WshSysEnv = WshShell.Environment("USER")
    to read

    Code:
    Set WshSysEnv = WshShell.Environment("SYSTEM")
    Last edited by BlackBox; 2013-10-25 at 08:44 PM. Reason: Please use [CODE] Tags

  3. #3
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,667
    Login to Give a bone
    0

    Default Re: Setting Environment Variable in login script doesn't show up in AutoCAD 2014!!! ARGH!!!

    On my PC (getenv "OS") returns "Windows_NT", but (getenv "PROMPT") returns nil. Probably has to do with where the values are stored in the registry.
    When you enter SET at the DOS command prompt does the variable display correctly? What is it you're trying to do?

  4. #4
    AUGI Addict bowlingbrad's Avatar
    Join Date
    2003-11
    Location
    Chicago
    Posts
    1,233
    Login to Give a bone
    0

    Default Re: Setting Environment Variable in login script doesn't show up in AutoCAD 2014!!! ARGH!!!

    typing SET gives me the value.
    I'm trying to set a variable to locate the computer. We have 3 offices and I want a simple (getenv) that reveals what office the user logged into. I have other portions of the login script doing office specific stuff too (not environment variables)

  5. #5
    AUGI Addict
    Join Date
    2015-12
    Posts
    2,095
    Login to Give a bone
    0

    Default Re: Setting Environment Variable in login script doesn't show up in AutoCAD 2014!!! ARGH!!!

    In order to get generic Windows ENV variables inside AutoCAD, you'll need to take another route. Might need to dig through the registry through a (vl-registry-read ...) call, or change your method of setting variables (e.g. dedicated registry keys and values, or a common network data file with location information).

  6. #6
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,106
    Login to Give a bone
    0

    Default Re: Setting Environment Variable in login script doesn't show up in AutoCAD 2014!!! ARGH!!!

    Here is a quick routine to get environment values through AutoLISP and the Shell environment.
    Code:
    (defun GetEnvVar (EnvVarName / objShell EnvVarValue )
      (setq objShell (vlax-get-or-create-object "Wscript.Shell")
    	EnvVarValue (vlax-invoke-method objShell 'ExpandEnvironmentStrings (strcat "%"EnvVarName"%")))
      (vlax-release-object objShell)
      EnvVarValue
      )
    This may not retrieve all environment variables.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  7. #7
    AUGI Addict bowlingbrad's Avatar
    Join Date
    2003-11
    Location
    Chicago
    Posts
    1,233
    Login to Give a bone
    0

    Default Re: Setting Environment Variable in login script doesn't show up in AutoCAD 2014!!! ARGH!!!

    I think I'm getting close with (vl-registry-read).... I'll post my findings.

  8. #8
    AUGI Addict bowlingbrad's Avatar
    Join Date
    2003-11
    Location
    Chicago
    Posts
    1,233
    Login to Give a bone
    0

    Default Re: Setting Environment Variable in login script doesn't show up in AutoCAD 2014!!! ARGH!!!

    my original vbs code was fine.

    I changed the way I access the environment variable using:
    Code:
    (vl-registry-read "HKEY_CURRENT_USER\\Environment" "GP_OFFICE")

Similar Threads

  1. 2014: Delete Key doesn't work on my Mac Book Pro in AutoCAD 2014
    By LemonTree in forum AutoCAD for Mac General
    Replies: 4
    Last Post: 2017-02-18, 06:28 AM
  2. 2014: Revit 2014 ISSUE - Beams print hidden lines (doesn't show up in viewports)
    By mark.moore677609 in forum Revit Structure - General
    Replies: 4
    Last Post: 2014-08-26, 12:42 PM
  3. Setting the ACAD environment variable on launch
    By jpcadconsulting347236 in forum AutoLISP
    Replies: 8
    Last Post: 2014-04-03, 04:14 PM
  4. 2014: Delete Key doesn't work on my Mac Book Pro in AutoCAD 2014
    By LemonTree in forum AutoCAD General
    Replies: 2
    Last Post: 2013-11-15, 03:04 PM
  5. Setting up AutoCAD 2007 in a network environment
    By thomasf in forum AutoCAD Customization
    Replies: 5
    Last Post: 2006-12-08, 09:29 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •