dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: shell run dialog

  1. #1
    Join Date
    Aug 2005
    Location
    southampton, UK
    Posts
    1,320

    shell run dialog

    i need to give my program a short name which is recognised so that it can be run easily, for example, by the shell run dialog. i.e. if i type in firefox, firefox is found and executed. how can i register a name like this?

    The reason i want to do this is because my exe could be moved around the file system, but i need to reliably start it from another process without knowing where it is on the file system.

    thanks
    With sufficient thrust, pigs fly just fine. However, this is not
    necessarily a good idea. It is hard to be sure where they are going to
    land, and it could be dangerous sitting under them as they fly
    overhead. -- RFC 1925

  2. #2
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,605

    Re: shell run dialog

    The reason i want to do this is because my exe could be moved around the file system
    Afraid, there is no connection between what you want and ability to your exe to be deliberately moved around the file system. I dont know even a single OS that would allow such odd behavior - I mean, finding executable anywhere it would be placed.

    Most of utilities runnable from Run dialog either are placed into system32 folder or register their locations in registry (either in SessionManager environment or in App Paths). Definitely, this does not allow them walk around the file system mindlessly remaining runnable at the same time.
    Last edited by Igor Vartanov; November 21st, 2007 at 06:20 AM.
    Best regards,
    Igor

  3. #3
    Join Date
    Aug 2005
    Location
    southampton, UK
    Posts
    1,320

    Re: shell run dialog

    Thanks, yeah i am gonna write exe location to registry everytime it runs.

    If someone happens to move the exe file then not run it, well tough shizzle
    With sufficient thrust, pigs fly just fine. However, this is not
    necessarily a good idea. It is hard to be sure where they are going to
    land, and it could be dangerous sitting under them as they fly
    overhead. -- RFC 1925

  4. #4
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,605

    Re: shell run dialog

    To be able to write to a registry key a process must have sufficient permission. And HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths and HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment appear to be editable to Administrators only.
    Best regards,
    Igor

  5. #5
    Join Date
    Nov 2007
    Posts
    613

    Re: shell run dialog

    To enable the operating system to find files in a specified folder you need to edit the 'autoexec.bat' file. It's in the root of your boot partition. Right-click the file, the context menu has an "Edit" option for this type of file. (In fact, it's a text file.)

    You need to modify the PATH environment variable.

    If you find there a line starting with "PATH=..." simply ignore it.

    The file may be empty. It doesn't matter.

    Go to the end of the file and write a line like this:
    @PATH=%PATH% + ";C:\MyFolder\MySubFolder;"
    (obviously with your own path)

    Save the file and restart your computer.

    Testing if it's ok:
    Open the command window (from Accessories) and type the commnad PATH. The value of the environment variable should be written in the window. Look if your path is there. If it's not, you made an error editing the autoexec.bat file. Fix it.

    If is there, everything is ok, the files in that folder will be found by the operating system no matter who, from where, requsts them.

    -------------------------------------------------------------------------

    Additional info about the PATH command:

    The PATH command reinitializes the %PATH% environment variable.

    The "@" symbol supresses output to the system console, otherwise the command will be written to the system console when the batch is executed. (outputs to the system console can also be disabled with an ECHO OFF command)

    The expression %PATH% is the previous content of the PATH environment variable, you add your own path to it.

    The " delimiters are necessary only if the path contain spaces.

    The ; character is a separator between two paths. If there are more such consecutive characters it's ok, the system will consider between empth paths. If the separator is missing, it's a serious error, the whole environment variable will be ignored and the system will use a default environment variable without the paths declared in autoexec.bat.

    The os adds automatically it's own important paths to the environment variable so you don't need to care if the "Windows" or "System32" folders are there or not.

    Errors made with the PATH command cannot stop the system from working normally but they can have negative effects on the applications relaying on the PATH settings.
    Last edited by srelu; November 26th, 2007 at 05:27 PM.

  6. #6
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,559

    Re: shell run dialog

    Why is your program moving around?

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)