Inno Setup Unknow Filename Prefix - installation

I'm trying to set the output folder of the compiled installer to the desktop.
This script can be runned by multiple people across multiple computers, that's why I need to use a dynamic script.
OutputDir= "{#Desktop}"
I'm able to use the prefix userdocs: but not userdesktop:.
//Works:
#define Path "userdocs:Visual Studio 2013\Projects\"
//Throws "Unknow filename prefix userdesktop:"
#define Desktop "userdesktop:";
Here is the documentation:
{userdesktop} & {commondesktop} *
The path to the desktop folder.
{userdocs} & {commondocs}
The path to the My Documents folder.
I also tried commomdesktop: with no success.

In that case you may want to use ISSI and its Constants.
#define ISSI_IncludePath "..\Inno Setup 5\ISSI\" ;path to ISSI
#include ISSI_IncludePath+"\_issi.isi"
[Setup]
OutputDir={#ISSI_myUserDesktop}

Related

Editing .rc resource files via script or command line?

Trying to automate some of our processes in a C++ Windows app build using Jenkins. What we would like to do is make the updating of the version information in the resource file (.rc) automatic. Currently there is a script that prompts user for which version that they want to release, and preps everything for automated building, i.e. creates branch etc.
We would like part of the process to update the .rc file. Are there tools to edit .rc files programatically that can be run from the command line?
First of all, you should put the code below in a .rc2 file that is neither interpreted nor modified by Visual Studio and include that file in your .rc file.
In order to yield the version strings, you need two helper functions that concatenate the stringified numbers into a string.
The variables F1 through F4 can be defined by including a header file. Ideally you would create a header from the user input that defines just those four variables. This keeps the whole rest of your code base unchanged. The method is identical for the product verion.
#define F1 1 // Defined by an included header
#define F2 2
#define F3 3
#define F4 4
// MyAppVersionInfo.rc2
#define STRTMP(V1, V2, V3, V4) #V1 "." #V2 "." #V3 "." #V4
#define STR(V1, V2, V3, V4) STRTMP(V1, V2, V3, V4)
#define FVC F1,F2,F3,F4
#define FVS STR(F1,F2,F3,F4)
VS_VERSION_INFO VERSIONINFO
FILEVERSION FVC
...
VALUE "FileVersion", FVS
Note that I chose very short identifiers in this example to keep stackoverflow.com happy.

What determines the location of the 'pathdef.m' file on Windows?

http://www.mathworks.com/support/solutions/en/data/1-5YQCPR/index.html?product=ML says:
By default, the 'pathdef.m' file may be located in either the
'$MATLABROOT/toolbox/local' directory or the '$USERPATH' directory,
where $MATLABROOT and $USERPATH are the directories displayed after
entering the commands matlabroot (e.g. C:\Program Files\MATLAB\R2013b) and userpath (e.g. C:\Users\francky\Documents\MATLAB)
So, what determines the location of the pathdef.m file on Windows (matlabroot vs. userpath)?
According to this help page:
By default, pathdef.m is in matlabroot/toolbox/local.
However, there is apparently more to it than that.
If we add matlabpath to the top of matlabrc.m, it will tell use the search path before it has even "set up" the search path:
MATLABPATH
C:\Program Files (x86)\MATLAB\R2013a\toolbox\local
>>
So the only thing on the path is matlabroot/toolbox/local and that's where MATLAB will find pathdef.m by default. Right? I thought so, but a simple test with a pathdef.m in userpath proved that in fact userpath was the first priority for pathdef.m. Why? Because in MATLAB, the working directory takes priority over anything on the matlabpath, and the startup folder is determined by userpath!
There are multiple ways to specify the startup working directory, with and without the use of userpath's functional form. I just verified that changing the "Start in:" property of the Windows shortcut will prevent the pathdef.m in the default userpath from running. You can achieve the same change in startup folder with the userpath(path) syntax, but then what would be the difference between the startup path and userpath unless you use the shortcut "Start in:" method?
To add to the confusion, the last line of the default pathdef.m under matlabroot/toolbox/local is p = [userpath,p];, so after matlabrc.m adds this to the path on startup, MATLAB will then give userpath precedence over matlabroot, if ther is a pathdef.m under userpath.

How to get the parent folder of a Windows user's profile path using C++

I am trying get the parent folder of a Windows user's profile path. But I couldn't find any "parameter" to get this using SHGetSpecialFolderPath, so far I am using CSIDL_PROFILE.
Expected Path:
Win7 - "C:\Users"
Windows XP - "C:\Documents and Settings"
For most purposes other than displaying the path to a user, it should work to append "\\.." (or "..\\" if it ends with a backslash) to the path in question.
With the shell libary version 6.0 you have the CSIDL_PROFILES (not to be confused with CSIDL_PROFILE) which gives you what you want. This value was removed (see here), you have to use your own workaround.
On any prior version you'll have to implement your own workaround, such as looking for the possible path separator(s), i.e. \ and / on Windows, and terminate the string at the last one. A simple version of this could use strrchr (or wcsrchr) to locate the backslash and then, assuming the string is writable, terminate the string at that location.
Example:
char* path;
// Retrieve the path at this point, e.g. "C:\\Users\\username"
char* lastSlash = strrchr(path, '\\');
if(!lastSlash)
lastSlash = strrchr(path, '/');
if(lastSlash)
*lastSlash = 0;
Or of course GetProfilesDirectory (that eluded me) which you pointed out in a comment to this answer.

How to convert legacy "C:\Documents and Settings" paths to "C:\Users"

I have some legacy data that was created on Windows XP. It contains absolute file names to files in users' My Documents directories. On Windows 7, these absolute references are no longer point to the correct place. For example what was "C:\Documents and Settings\Gareth\My Documents\readme.txt" should now be "C:\Users\Gareth\Documents\readme.txt".
Many Win32 functions are happy to take the file names under "C:\Documents and Settings" and to behind the scenes convert them to the new file names, however there are functions we use that don't do this. Is there a Windows API that I can use to convert these file names to the new locations?
Obviously, I could do string search and replace, but that wouldn't be guaranteed to work under all circumstances. Because there are Windows functions that seem to do the substitution it feels like there ought to be a published function I can call to do the same thing.
Just to clarify my question: I'm looking for a function that does this:
Input: "C:\Documents and Settings\Gareth\My Documents\readme.txt"
Output: "C:\Users\Gareth\Documents\readme.txt"
or
Input: "C:\Documents and Settings\Gareth\My Documents\"
Output: "C:\Users\Gareth\Documents\"
This works with symbolic links. That should work on any function that takes a path, MSDN documentation is here: msdn.microsoft.com/en-us/library/aa365680%28v=VS.85%29.aspx
I verified MapFileAndCheckSum(), it works fine. Windows7, compiled with UNICODE in effect.
#include "stdafx.h"
#include <windows.h>
#include <assert.h>
#include <imagehlp.h>
#pragma comment(lib, "imagehlp.lib")
int _tmain(int argc, _TCHAR* argv[])
{
DWORD hdrsum, chksum;
const wchar_t* path = L"c:\\documents and settings\\hpassant\\my documents\\test.exe";
DWORD retval = MapFileAndCheckSum(path, &hdrsum, &chksum);
assert(retval == 0);
return 0;
}
Is it what you need?
%USERPROFILE%\My Documents
I'm not sure where exactly you're using this (and it's been a while since I've used Windows), but I remember being able to use the %HOMEPATH% variable to get the current user's Documents & Settings directory: \Documents and Settings{username}. I think that this works with the updated Windows 7 paths, too.

Checking if a Folder/File is Hidden/System in Windows C/C++

I am writing a Cross platform application using C++/STL/Boost and I realized they do not provide a way to check if a folder or file is hidden or is a system file in Windows.
What's the simplest way to do this in C/C++ for Windows ?
Ideally I have a std::string with the path (either to a file or folder), and would return if it's hidden or is a system file. best if it works across all windows versions. I am using MinGW g++ to compile this as well.
GetFileAttributes will work for this.
It takes a path to either a file or a directory as a parameter and returns set of flags including FILE_ATTRIBUTE_HIDDEN and FILE_ATTRIBUTE_SYSTEM.
DWORD attributes = GetFileAttributes(path);
if (attributes & FILE_ATTRIBUTE_HIDDEN) ...
if (attributes & FILE_ATTRIBUTE_SYSTEM) ...

Resources