Is there a universal variable for the path to a program


  1. Posts : 43
    Windows 10
       #1

    Is there a universal variable for the path to a program


    I have noticed on several occasions that during the installation of a program downloaded from the internet that there was some sort of variable in the path to the installation folder I would just accept the default and the installation went OK.
    I assumed that the variable was to accommodate the different OS's.
    I have a small program that I created that I wanted to make available to the public. However, this program was created with the thought of using it myself. so I did not pay attention to the paths except to make it work. Now that I wish to make it available I should make the installation easier. The current path on my computer is "C:\users\bill\documents\FUND" and it branches from there. I assume that the variable in question is to replace the user. I hope I have made this clear enough that it can be understood.
    I'm looking for a place that describes this variable and how I might be able to use it in my installation instructions.
    Bill
      My Computer


  2. Posts : 5,478
    2004
       #2

    It would be best to use a relative path so the end user can place your program anywhere they want.

    You don't say what language you are using but in powershell this will give you the current directory or working directory for .NET
    Code:
    (Get-Item -Path ".\" -Verbose).FullName
    You could then add your directory structure to the end of this path.

    Another approach is to have the program somewhere (perhaps "C:\Program Files" but could be anywhere) and store the data somewhere else (like the users %appdata% or documents directory).

    Again in Powershell (other languages have different syntax but the idea is the same) these would be:
    Code:
    $env:LOCALAPPDATA\FUND --->  C:\Users\bill\AppData\Local\FUND
    $env:homeDrive$env:homePath\Documents\FUND  -->   C:\Users\bill\Documents\FUND
      My Computer


  3. Posts : 43
    Windows 10
    Thread Starter
       #3

    The program is written in Quattro Pro and uses QP macros as well as Perfectscript macros. Both of these are part of WordPerfect Office X7.
    I am not very tech savvy so talk to me as if I am from an older generation . I am, in fact, 85.
    Bill
      My Computer


  4. Posts : 8,057
    windows 10
       #4

    Path is a separate thing if from a Cmd prompt you type set it will show you the path this means windows etc will look in those folders for any file to run. You talking insulation folder how many files in your programme you can get free software which will package your software into an install and that will copy the files set folders etc. It depends on your software which is best for you
      My Computer


  5. Posts : 5,478
    2004
       #5

    I don't know these programs I'm afraid.

    Having a look for some documentation I found this: Batch export WordPerfect documents to PDF or DOC - Sample Macros - PerfectScript - OfficeCommunity.com

    Application (WordPerfect; "WordPerfect"; Default!; "EN")
    ExtPos := StrPos (?Name; ".wpd")
    NombDoc = ?Path + SubStr (?Name; 1; ExtPos-1) + ".pdf "
    PdfDlg (NombDoc)
    Return
    This macro appears to be changing .wpd to .pdf and the .pdf is created in the place ?Path with name being the same just changing File_name.wpd to File_name.pdf. So it appears that you can use ?Path and this will define where your program is.

    At a guess therefore if you replaced in your program anywhere you've explicitly typed C:\Users\bill\Documents\FUND\ with ?Path then it might work. If you do this and it works for you then it would work for anyone.

    Hopefully someone how uses these programs will be able to help but if not it may be worth a try.
      My Computer


  6. Posts : 42,734
    Win 10 Pro (22H2) (2nd PC is 22H2)
       #6

    Hi, I think you're thinking of e.g.
    %userprofile%
    - an environmental variable in Windows.
    Try literally typing that into the address bar in explorer. That should take you to
    C:\users\bill\

    For more variables, open a command prompt and simply type
    set

    This relies on that string being interpreted by Windows, of course, which you mentioned you wanted to happen during installation.
      My Computers


  7. Posts : 43
    Windows 10
    Thread Starter
       #7

    Try literally typing that into the address bar in explorer. That should take you to
    C:\users\bill\
    Unless literally means something different than I understand the results are inconsistent. I just typed in $userprofile$ and the W10 explorer did a search of C: drive and when not found it searched the internet and returned this."Server not found

    Firefox can't find the server at www.$userprofile$.com." I'll keep working at it.

    Bill
      My Computer


  8. Posts : 42,734
    Win 10 Pro (22H2) (2nd PC is 22H2)
       #8

    No, literally is exactly - try it this way. Copy all the characters on the line below
    %userprofile%
    exactly as you see them into the address bar of explorer.
    Those are %'s not $'s
      My Computers


  9. Posts : 43
    Windows 10
    Thread Starter
       #9

    dalchina said:
    No, literally is exactly - try it this way. Copy all the characters on the line below
    %userprofile%
    exactly as you see them into the address bar of explorer.
    Those are %'s not $'s
    Now it works when I use the correct prefix and suffix % % %%%%. THANKS.

    I would like to go to the documents folder then I can add one new folder FUND. I have tried %userprofile%+\documents\ Windows doesn't like it.

    Bill
      My Computer


  10. Posts : 42,734
    Win 10 Pro (22H2) (2nd PC is 22H2)
       #10

    Hi, that's simply
    %userprofile%\documents
      My Computers


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 15:04.
Find Us




Windows 10 Forums