Windows 10: Is there a universal variable for the path to a program

  1.    07 Aug 2016 #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 ComputerSystem Spec

  2.    07 Aug 2016 #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 ComputerSystem Spec

  3.    07 Aug 2016 #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 ComputerSystem Spec

  4.    07 Aug 2016 #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 ComputerSystem Spec

  5.    07 Aug 2016 #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 ComputerSystem Spec

  6.    07 Aug 2016 #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 ComputerSystem Spec

  7.    08 Aug 2016 #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 ComputerSystem Spec

  8.    08 Aug 2016 #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 ComputerSystem Spec

  9.    08 Aug 2016 #9

    dalchina said: View Post
    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 ComputerSystem Spec

  10.    08 Aug 2016 #10

    Hi, that's simply
    %userprofile%\documents
      My ComputerSystem Spec


 

Related Threads
Source: The path from a desktop app to a Universal Windows Platform (UWP) app | Building Apps for Windows
I had to restore my PC to factory settings because of a virus (maybe overkill, not sure) and reinstalled the Java JDK and editing the Environment Variable for Path. First try gave me this: 68432 Second try gave me this (I can't remember how):...
Hi all, I am trying to write a batch file in Windows 10 to output day of week (Monday, Tuesday etc) to variable do that I can do certain procedures on differnt days o the week and am having major problems. If I type DATE /T at command prompt I...
When I create a shortcut to file in Program Files, the target path for that shortcut will be to Program Files (x86), even though the start in path will be correct. Furthermore, even though the target path is incorrect and no icon is displayed for...
This is pretty outrageous! I did not bargain for hours of my time to figure out the new, improved Windows 10. Not only did I lose admin status, half of my bookmarked favorites have disappeared. I've seen the "take ownership..." articles, and...
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 01:49.
Find Us