How to add new path to current system path

rodbernardorodbernardo Member Posts: 34
edited 2008-05-13 in NAV Tips & Tricks
Hello gurus,

How can I add a new path string to the current system path?

Using Environ('Path') we can able to retrieve the current system path, but how to add new path string?

Current System Path:

Path = c:\windows;c:\windows\system32;

I want to add this path c:\temp;

New system path will be:

Path := c:\windows;c:\windows\system32;c:\temp;

Any work around? Which automation should we use?

Thanks in advance.


Rodel
Sydney, Australia
Rodel Bernardo
Pressure is an opportunity.

Comments

  • tinoruijstinoruijs Member Posts: 1,226
    Use the 'Windows Script Host Object Model'.FileSystemObject'

    CreateFolder(NewFolder : Text[100]) : Boolean
    IF ISCLEAR(FileSystem) THEN
    IF NOT CREATE(FileSystem) THEN
    EXIT;

    FileSystem.CreateFolder(NewFolder);


    Take a look at the following post:
    http://www.mibuso.com/forum/viewtopic.php?t=1853

    Tino Ruijs
    Microsoft Dynamics NAV specialist
  • garakgarak Member Posts: 3,263
    the Systemvariable Path is stored in the registry key
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\Path

    so, you can use WshShell

    Name DataType Subtype Length
    WshShell Automation 'Windows Script Host Object Model'.WshShell


    if isclear(WshShell) then
    create(WshShell);


    RegKey := 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\Path';

    Variantvariable := WshShell.RegRead(RegKey);
    .....


    WshShell.RegWrite(RegKey,YOURNEWVAUE);
    clear(WshShell);

    Regards
    Do you make it right, it works too!
  • rodbernardorodbernardo Member Posts: 34
    Genius, I got it working.

    Thanks guys.


    Rodel
    Sydney Australia
    Rodel Bernardo
    Pressure is an opportunity.
  • krikikriki Member, Moderator Posts: 9,112
    [Topic moved from Navision forum to Navision Tips & Tricks forum]
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.