Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. enviromental access problem

enviromental access problem

Scheduled Pinned Locked Moved C / C++ / MFC
c++windows-adminlinuxhelpworkspace
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mogaambo
    wrote on last edited by
    #1

    I had created variable in user section , using the following code 'defining variables dim objShell, colUserEnvVars 'initializing all variables Set objShell = WScript.CreateObject("WScript.Shell") Set colUserEnvVars = objShell.Environment("System") 'Output File for registry information. colUserEnvVars("rahul") = "rahul" but i cannot read the same from c++, for this i have to restart the system, but Wscript.Echo colUserEnvVars("DeloitteAuditShare123") read the value without restarting ths system.

    “You will never be a leader unless you first learn to follow and be led.” –Tiorio "Coming together is a beginning, staying together is progress, and working together is success." Henry Ford

    G S 2 Replies Last reply
    0
    • M Mogaambo

      I had created variable in user section , using the following code 'defining variables dim objShell, colUserEnvVars 'initializing all variables Set objShell = WScript.CreateObject("WScript.Shell") Set colUserEnvVars = objShell.Environment("System") 'Output File for registry information. colUserEnvVars("rahul") = "rahul" but i cannot read the same from c++, for this i have to restart the system, but Wscript.Echo colUserEnvVars("DeloitteAuditShare123") read the value without restarting ths system.

      “You will never be a leader unless you first learn to follow and be led.” –Tiorio "Coming together is a beginning, staying together is progress, and working together is success." Henry Ford

      G Offline
      G Offline
      Garth J Lancaster
      wrote on last edited by
      #2

      how/from where are you starting the c++ program ? if you dont start it in the same process (maybe that's badly worded) may 'shell'/session ie start it from the VBScript process, it won't have access to the same environment - you would need to have your VBScript modify the 'parent' environment - quite a hard task iirc .. I think you need to look at something like 'setx' http://www.ss64.com/nt/setx.html[^] 'g'

      1 Reply Last reply
      0
      • M Mogaambo

        I had created variable in user section , using the following code 'defining variables dim objShell, colUserEnvVars 'initializing all variables Set objShell = WScript.CreateObject("WScript.Shell") Set colUserEnvVars = objShell.Environment("System") 'Output File for registry information. colUserEnvVars("rahul") = "rahul" but i cannot read the same from c++, for this i have to restart the system, but Wscript.Echo colUserEnvVars("DeloitteAuditShare123") read the value without restarting ths system.

        “You will never be a leader unless you first learn to follow and be led.” –Tiorio "Coming together is a beginning, staying together is progress, and working together is success." Henry Ford

        S Offline
        S Offline
        Stuart Dootson
        wrote on last edited by
        #3

        Calling SetEnvironmentVariable has no effect on the system environment variables. To programmatically add or modify system environment variables, add them to the HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment registry key, then broadcast a WM_SETTINGCHANGE message with lParam set to the string "Environment". This allows applications, such as the shell, to pick up your updates. Note that the values of the environment variables listed in this key are limited to 1024 characters[^]

        Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups