InstallScript check if installation path is root drive - installshield

How to check if user has selected the root drive for installation. Installation should not proceed if user selects the root drive and prompt user to select another path.
Right now i am using following piece of code, is there better option to do same thing -
if (GetDir (svSelectedDir, svDirNameOnly) < 0) then
// Report the error.
MessageBox ("Cannot select the root drive for installation. Please select valid path.", SEVERE);
else
// proceed with installation.
endif;

Try using the built-in ROOTDRIVE property.
But what exactly is your definition of 'root drive' ?

Related

Inno Setup - How to replace UserName with string

first attempt at posting this question was with severe jet lag. This re-edit of the question I only have the associated sleep deprivation...
I want to know the best way to use the installer to capture path information and then remove any reference to the user profile.
My program is designed to run from a central network location. To reduce network traffic some files are copied to a local drive, eg. AppData\MyProg\
I use a file browse dialogue so the person installing can specify the location:
pg_LocalPaths := CreateInputDirPage(pg_CentralPaths.id,
'Confirm File Locations For User Settings', 'To improve user experience these locations should be off the network.',
'Default Locations are:', False, 'New Folder');
// Add file browswer item (with an empty caption)
pg_LocalPaths.Add('Supporting files will be copied here by the application:');
pg_LocalPaths.Add('User settings (for a single user) will be saved here:');
// Set initial value
pg_LocalPaths.Values[0] := GetPreviousData('pg_LocalPaths0', ExpandConstant('{userappdata}\{#pFolder}'));
pg_LocalPaths.Values[1] := GetPreviousData('pg_LocalPaths1', ExpandConstant('{userappdata}\{#pFolder}'));
During install the local drive location is specified and stored in a config file.
An issue that I failed to predict is that when the program is installed, the path in the config file is defined for a single user, namely the user performing the install. In practice any user should be able to run the program...
To get the correct path for any given user, my software looks for a string "{UserName}" and replaces it with: Environ(UserName)
MyPath = Replace(MyPath, "{UserName}", Environ(UserName))
So, for example, in the installer I need to replace:
C:\Users\My Name\My Program OR C:\Users\My Admin\My Program
with something like:
C:\Users\\{UserName}\My Program
I alreay have this working in My Program but I am not sure of the best way to get it working in Inno... My inital thought was to write the config file like this:
StringChangeEx(MyPath, "My Name", "{UserName}", True)
Would like some perspective on this, not sure how to get it working for all situations.
Cheers,
You're doing it the wrong way.
Don't store the complete path in the config file; merely store a value that indicates that the user wishes to store data in the usual per-user location. (Or don't store any value, since that should be the default anyway.)
Then in your application, on every run of your application, use the Shell API to fetch the current AppData path for the current user and append your app's unique subfolder to this.
Note that it is perfectly valid for the user's AppData path to not contain their username, and not even be on C:. Don't make assumptions; use the Shell API. That's what it's for.
(Exactly which one to use and how to call it varies depending on target OS and your programming language of choice, which you haven't specified.)

Exception Message: There is no working folder mapping for

I am trying to test automated builds in tfs/vs.net 2012. I have set the workpaths in the source control explorer but now I am getting an error:
Exception Message: There is no working folder mapping for $/testing/buildtest. (type ItemNotMappedException)
I had the same problem. Turned out I had forgotten to expand the Items to Build section of the Process tab. To fix you need to:
Edit build definition
Open Process tab on left
Open the 1. Required section
open up Items to Build
ensure the Projects to Build is pointed to the correct .sln
You need to map the root of the team project (in your case "testing) which is not done.
The local path should be "c:\dev\testing\buildtest".
How is your BuilDefinition setup?
In my case clicking on the Build Agent Folder (...) button revealed that the $(SourceDir) wasn't set, indicating the mapping was broken.
This can also happen if you forget to include your parent folder of the source code in the Source Settings in the build definition.
$/Source/Code/ParentOfSolution
Working folders basically creates a white list of files for the build to look at and use so it needs to contain your source code that is referenced by your sln and any DLL's that your code references.
In my case the exception message "There is no working folder mapping for xxx." was thrown at Microsoft.TeamFoundation.VersionControl.Client.Client.GetLocalWorkspace(String localPath, Boolean throwIfNotFound) out of my own code:
var changesets = myRealTfsServer.QueryHistory( path, versionSpec, 0, RecursionType.Full, null, new ChangesetVersionSpec( 1 ), versionSpec, 2, true, true, false, false );
My solution is to use the TFS path '$/' to specify the path parameter, which is actually not as declared in this page in MSDN which says this path should be a local path.

Install shield - set targetdir to c:\Test

I'm using Installshield and want to set the destionation folder to c:\test.
the problem is that the dialog does not allow it.
What is the solution for this ?
Your dialog box looks like an older version of Installshield, but in any case this might help others who are looking to do the same thing.
If you do not want to (or cannot) create the custom destination path (method described in other answers), a simple alternative is setting INSTALLDIR to [WindowsVolume]test.
This installs the tool in C:\test. Of course, if the system does not have a C: drive, it installs it in the available drive.
See:
Q104964: HOWTO: Creating a Custom Destination Path
BTW, it is possible that the system doesn't have a C: drive.
Go to Setup.rul in the OnFirstUIBefore function if I remember correctly and add this lines:
// Create a list for system information.
listInfo = ListCreate (STRINGLIST);
// Get the boot drive.
if (GetSystemInfo (BOOTUPDRIVE, nvResult, svResult) < 0) then
szError = "Couldn't get BOOTUPDRIVE info.";
else
TARGETDIR = svResult ^ "Test";
endif;
This guarantees that if the C:\ is not the boot up drive it will be changed to the boot drive.

Inno-Setup checking file location prior to installation, then using it during installation

I need to check for the location of a file during program installation utilizing inno setup. I then need inno setup to use the location of that file in the "Filename" line to create a desktop ICON for program initialization. I have the code for the "Icons" option working fine with the exception of how to do the above.
Here is the line of code I am currently using;
Name: "{commondesktop}\SA - NH Bricscad V12"; Filename:"**c:\program files\septic assistant\new hampshire\support\**SA - NH Bricscad V12.exe"; IconFilename: "C:\Program Files\Septic Assistant\New Hampshire\Support\Bricscadlogo.ico"; Comment: "Septic Assistant the only Septic Design Program"
Hi-Lited section would be the path to the exe file that I need inno setup to search for.
Any assistance with this would be very much appreciated.
Bruce
Just use a {code:...} constant and corresponding [Code] function that returns the appropriate path for your [Icons] entry. You will probably also want to use a Check function to avoid installing the icon in the case that you cannot find the correct location.
Another option is to use a {reg:...} constant, assuming that the path you are trying to locate is specified somewhere in the registry (which is usually the case).
If the path is not already specified somewhere well-defined in the Registry when the other app is installed, and you don't have some other means to quickly identify where the other app is located (note that doing a global search of the user's HD is not a valid option), then you should add a page that prompts the user to enter the location themselves (which you can then verify that they have chosen the correct location). You can see examples of prompting the user for information and then doing something with that info in the CodeDlg.iss example included with Inno, and in the ISXKB wiki.

NSIS uninstaller RMDir from appdata folder

is there a way to delete files from the c:\users{username}\appdata\local folder? is there a predefined variable for this? Win 7 stores some information in there from my app and i would like to delete theses files upon uninstall.
I know there is a predefined $APPDATA variable but it goes to \roaming not \local
is there a predifeined variable for c:\users{username}\ ??
This path and many others is defined in constants (look at the 4.2.3 section of the Chapter 4 of the manual).
I think you are looking for the $LOCALAPPDATA value that states it is "The local (nonroaming) application data directory".
Remember that you can choose between your account and all users folders resolution of the path constants with the SetShellVarContext command.

Resources