Results 1 to 6 of 6

Thread: Environment Variables??

  1. #1

    Thread Starter
    Junior Member w8taminute's Avatar
    Join Date
    Aug 2006
    Posts
    24

    Environment Variables??

    I am going crazy!
    Does anyone know how to create a permanent environment variable via run-time or a batch file?

    Thanks

  2. #2
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: Environment Variables??

    Take a look at the Environment.SetEnvironmentVariable method.
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

  3. #3

    Thread Starter
    Junior Member w8taminute's Avatar
    Join Date
    Aug 2006
    Posts
    24

    Re: Environment Variables??

    Environment.SetEnvironmentVariable looks like it might work.

    What about with a batch file?

  4. #4
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    Re: Environment Variables??

    Quote Originally Posted by w8taminute
    What about with a batch file?
    What about it? That a batch file thing, not a vb thing.
    Last edited by JuggaloBrotha; Jun 10th, 2008 at 08:38 PM.
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

  5. #5
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538

    Re: Environment Variables??

    Via a batch file:
    Code:
    SETX MyVarName "Hello World!"
    Via .Net code:
    Code:
    Public Class Form1
    
        Private Sub Form1_Load(ByVal sender As Object, _
        ByVal e As System.EventArgs) Handles Me.Load
            Environment.SetEnvironmentVariable ("MyNewVar", _
            "Hello World!", EnvironmentVariableTarget.User)    
        End Sub
    
    End Class
    I've just tried and tested both and they insert user environment variables fine.
    Last edited by alex_read; Jun 10th, 2008 at 12:41 PM.

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  6. #6

    Thread Starter
    Junior Member w8taminute's Avatar
    Join Date
    Aug 2006
    Posts
    24

    Resolved Re: Environment Variables??

    Thanks alot!

Posting Permissions

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



Click Here to Expand Forum to Full Width