locked
How to shell a relative path exe file? RRS feed

  • Question

  • Hello all as the question goes, how do i make an absolute path into a relative one?

    As of now my codes look something like this :"Shell(F:\FYP_3\FYP_1\Chinese_version_1.0\MDS_MOdified_ChiVer\eSimulator\debug", vbNormalFocus)"

    However my knowledge of HTML tells me relative pathing would loook something like this "Shell(~\FYP_3\FYP_1\Chinese_version_1.0\MDS_MOdified_ChiVer\MicromouseSimulator\debug).

    But it did not work as it should be. So how should i go about tackling this problem??

    Sunday, June 24, 2012 3:53 AM

Answers

  • You can make the path an absolute one - the original path was absolute. That path was very unsuitable, because you cannot assume that all PCs will have a drive F. But you can easily make an absolute path that will exist for every PC.

    If you want to shift it around, then how do you know where it has shifted to? To execute that file you need to either:

    - Set the current folder (eg, F:\) and use a relative path eg "FYP_3\FYP_1\Chinese_version_1.0\MDS_MOdified_ChiVer\eSimulator\debug", or
    - Build an absolute path from the folder and the relative path eg. "F:\FYP_3\FYP_1\Chinese_version_1.0\MDS_MOdified_ChiVer\eSimulator\debug"

    In either case, you need to know the full path.

    The process I referred to is the Process class. You should use this instead of Shell. http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspx

    • Edited by Acamar Sunday, June 24, 2012 6:32 AM sp
    • Proposed as answer by Mark Liu-lxf Monday, June 25, 2012 7:43 AM
    • Marked as answer by Mark Liu-lxf Tuesday, July 3, 2012 9:21 AM
    Sunday, June 24, 2012 6:29 AM

All replies

  • A relative path simply starts at the current folder:

    Shell("FYP_3\FYP_1\Chinese_version_1.0\MDS_MOdified_ChiVer\MicromouseSimulator\debug")

    But that's only going to work if you somehow set the current path to

    "F:\"

    The shell command will look for FYP_3 in the current folder.   The problem is going to be in setting the current folder to the correct location.   If you can do that, then you may as well create an absolute path using that location. You should be using the Process class instead of the Shell command.

    Sunday, June 24, 2012 4:53 AM
  • I'm sorry i dont quite understand you. Because this folder is going to be shifted around, so i can't exactly make the path an absolute one...

    By process you mean creating a new sub?

    Sunday, June 24, 2012 5:58 AM
  • You can make the path an absolute one - the original path was absolute. That path was very unsuitable, because you cannot assume that all PCs will have a drive F. But you can easily make an absolute path that will exist for every PC.

    If you want to shift it around, then how do you know where it has shifted to? To execute that file you need to either:

    - Set the current folder (eg, F:\) and use a relative path eg "FYP_3\FYP_1\Chinese_version_1.0\MDS_MOdified_ChiVer\eSimulator\debug", or
    - Build an absolute path from the folder and the relative path eg. "F:\FYP_3\FYP_1\Chinese_version_1.0\MDS_MOdified_ChiVer\eSimulator\debug"

    In either case, you need to know the full path.

    The process I referred to is the Process class. You should use this instead of Shell. http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspx

    • Edited by Acamar Sunday, June 24, 2012 6:32 AM sp
    • Proposed as answer by Mark Liu-lxf Monday, June 25, 2012 7:43 AM
    • Marked as answer by Mark Liu-lxf Tuesday, July 3, 2012 9:21 AM
    Sunday, June 24, 2012 6:29 AM
  • Hello,

    You are currently in the VB for Net forum, you can try the scripting guys forum for more support in your part of interest.

    http://social.technet.microsoft.com/Forums/en-US/ITCG/threads


    Success
    Cor

    Sunday, June 24, 2012 9:24 AM