Jump to content

Permanently add to the Path Variable?


Recommended Posts

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
        Return
    EndSwitch
    $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()
    EndIf
EndFunc

:P

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...