Jump to content
Sign in to follow this  

Permanently add to the Path Variable?

Recommended Posts


Other than going into system -> advanced -> environment variables -> path -> edit and appending a path to the end of it, is there some better/safer way for autoit to do this? (Doing path=%PATH%;c:\program.exe in cmd is not permanent)

Share this post

Link to post
Share on other sites

Just use this UDF I use for making a permanent change to the systems path.

; 1st parameter = "User" or "System"
; 2nd parameter = Path to add

; example
_Path('System', '%SystemRoot%\SystemFiles')

Func _Path($type, $value)
    ; adds a folder to permanently become part of the systems path.
    Local $environment, $old, $new, $semicolon
    Switch $type
        Case 'System'
            $environment = 'HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment'
        Case 'User'
            $environment = 'HKCU\Environment'
        Case Else
    $old = RegRead($environment, 'Path')
    If $old <> '' Then $semicolon = ';'
    If Not StringInStr($old, $value) Then
        $new = $old & $semicolon & $value
        If RegWrite($environment, 'Path', 'Reg_Expand_sz', $new) Then EnvUpdate()


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.