Inno Setup - "New Folder" is automatically added to a selected destination folder - inno-setup

I want to install/extract all files into the folder I chose from the Setup Wizard. However I don't get to it, because there is always a sub directory created.
For example, if I choose: C:\MyFolder, the installer automatically adds New Folder to it.
How do I install without any auto made sub directory?
My code:
[Setup]
DefaultDirName={sd}\
DisableDirPage=no
And here an example:
I chose Directory: C:\Users\Administrator\Desktop\Neuer Ordner\123
However it selects the directory:
C:\Users\Administrator\Desktop\Neuer Ordner\123\New Folder
I don't want to use the New folder but simply use the chosen 123 folder.

By default, Inno Setup tries to preserve the last component of the path, if you choose another target path.
So if the default path (DefaultDirName) is like C:\Program Files\My Program and you choose D:\Programs, it will automatically append the My Program to become D:\Programs\My Program.
In your case, the Inno Setup is confused by the default path lacking any subfolder. And it (not really correctly) appends the New folder instead. Are you sure you really want to install to C:\ root?
Anyway, if that's intentional, set the AppendDefaultDirName to no.
See the documentation on the AppendDefaultDirName directive:
By default, when a folder in the dialog displayed by the Browse... button on the Select Destination Location wizard page is clicked, Setup automatically appends the last component of DefaultDirName onto the new path. For example, if DefaultDirName is {pf}\My Program and "Z:\" is clicked, the new path will become "Z:\My Program".
Setting this directive to no disables the aforementioned behavior. In addition, it causes a Make New Folder button to appear on the dialog.

Related

Inno Setup - how to use a user selected directory defined by a msgbox selection in the [files] destination [duplicate]

Running Inno Setup 5.5.6. I corrected an error in my DefaultDirName value, but no matter what I do, the program continues to try to install in the old, erroneous location. Even when I set it to a value matching one of the examples:
DefaultDirName={pf}\My Program
the program continues to choose the old, incorrect path.
How do I get Inno to use the corrected DefaultDirName?
Even though the previous install went to the wrong destination directory, the install did complete. According to the documentation for DefaultDirName:
If UsePreviousAppDir is yes (the default) and Setup finds a previous
version of the same application is already installed, it will
substitute the default directory name with the directory selected
previously.
So my previous installation was overriding the new DefaultDirName. Once I uninstalled the program and re-ran the installer, it began using my corrected DefaultDirName.
Set the AppendDefaultDirName directive to no, e.g.:
[Setup]
...
AppendDefaultDirName=no
As the reference says (emphasized by me):
By default, when a folder in the dialog displayed by the Browse...
button on the Select Destination Location wizard page is clicked,
Setup automatically appends the last component of DefaultDirName onto
the new path.
For example, if DefaultDirName is {pf}\My Program and "Z:\" is clicked, the new path will become "Z:\My Program".
Setting this directive to no disables the aforementioned behavior. In
addition, it causes a Make New Folder button to appear on the dialog.

How to move a Visual Studio Code workspace to a new location painlessly?

I thought VS Code saves all the relevant metadata in .vscode folder and .code-workspace file and as these are contained within the workspace folder I assumed it's all self-contained and shouldn't cause problems when moved. But apparently I was gravely mistaken.
After moving my workspace folder to a new location and altering folder paths saved in .code-workspace file accordingly all my opened editor panes and the bottom panel are gone. What I have now is a nice Welcome window.
I'm aware of what the official guide recommends, but that's only moving .code-worskpace metafile - the folder still stays in place.
I've just run into the same issue. My workspace wasn't saved to a file at all (I just use the "Open with Code" option on each project folder), and the Save Workspace As option didn't help as it just created a JSON file with a couple of empty objects in it (which probably makes sense as I haven't really modified any workspace settings, I just want to preserve my open editors and things like that).
On Windows at least, it seems that those kinds of "workspace" settings are actually stored within subfolders of %APPDATA%\Code\User\workspaceStorage, and an SQLite database file is used to store the actual settings, so this is what I ended up doing:
Move your folder to the new location on disk (close all VS Code windows first)
Open the new folder location with VS Code (you'll just get the Welcome tab at this stage, but we just need it to create a settings storage folder for the new location). Then close VS code again.
Open %APPDATA%\Code\User\workspaceStorage in File Explorer, go into each subfolder and open workspace.json (in any old text editor). In my case at least, it only contains a folder property, which is path of the folder that this settings folder relates to (but just changing this won't help us at all, it was the first thing I tried). Use this to figure out which of these subfolders relate to the old and new paths.
Copy state.vscdb from old to new, and delete state.vscdb.backup in new.
Open state.vscdb in new in some sort of SQLite database file editor (I used DB Browser for SQLite and it worked fine, but there's also SQLiteStudio which looks like it might be better in general).
Run an UPDATE query to update all the paths in the database. They seem to be stored in three different formats/levels of escaping - between folders there can be a forward slash, two backslashes, or four backslashes. In my case I wanted to move my project folder from the root of my Windows user folder into my usual documents folder which is within OneDrive, so my query was along the lines of the following, as I only needed to change the middle section of each path. You might have to do something more complicated if you are moving to a different drive for example (would need to have a look at all the existing paths in the database to see how they are encoded).
UPDATE `ItemTable` SET `value` = REPLACE(REPLACE(REPLACE(`value`, 'User/Project', 'User/OneDrive/Documents/Project'), 'User\\Project', 'User\\OneDrive\\Documents\\Project'), 'User\\\\Project', 'User\\\\OneDrive\\\\Documents\\\\Project')
After saving the database, I just opened the new folder in VS Code, and everything seems to have loaded up exactly as it was in the old location :)
(Also just in case anyone is curious, the subfolder names in workspaceStorage seem to be some sort of hash based on the path, because if you delete the subfolder that relates to a folder you've previously opened in VS Code and then open that folder in Code again, it recreates the same subfolder name. So that means just updating the old workspace.json and database file in-place won't work)
Scenario 1 - Moving the .code-workspace file The xxx.code-workspace file that defines your project folder location(s) is in JSON format. It has a "folders" section and a "settings" section. If you just mant to move the location of the xxx.code-workspace all that is needed is to go to File->Save Workspace As..., browse to the new location, select the name you want to give the workspace and it will save it with a .code-workspace extension. All of the "path" entries in the "folders" section are changed to a path relative to the new location.
Scenario 2 - Moving the entire workspace. If you want to move the entire workspace to a new location and the .code-workspace file is in the root directory of your workspace, just move the old workspace to the new location. The contents of the .code-workspace file will still be correct. Just select File->Open Workspace..., navigate to the new location and open the .code-workspace file.
Scenario 3 - When you .code-workspace folder is stored in a different location. If you store all of your .code-workspace files in a location apart from the actual workspace, the simplest way to move the workspace is a two step process:
With your workspace open, do File->Save Workspace As... and save the .code workspace file to the root directory of your workspace.
Move the workspace to the new location.
File->Save Workspace As... and save the .code workspace file to its location.
Close VS Code and delete the .code-workspace folder that's in the root directory of your resource, so that future settings changes will be saved to the correct workspace.

How do I delete a file using the "Add File Removal"?

How do I delete a file using the "Add File Removal"?
In InstallShield->Application Data->Files and Folders->I go to the parent directory.
Then I right click in "Destination computer's Files and select "Add File Removal".
If I select the "Remove files from the folder" radio button, how do I delete a specific sub-directory (i.e. \DirectoryToRemove, instead of a file?
The folder described by the radio buttons is the one listed after Location (the blacked out part of your screen capture). You can either remove files from the location in question, or the folder itself. If you want to remove a child of that folder, you will have to add a file removal to that folder, perhaps adding the folder first.
This is built upon the RemoveFile table, which is the source of the requirement that a folder be empty if you want to remove it. However if you go directly to the table, you can avoid creating a directory entry for a subdirectory by referencing a Property instead of a Directory. (If you go that route, note you will then have to ensure the referenced property has the correct value.)

How to open last opned folder in QFileDialog using PyQt

I want to know is it possible to open last browsed folder using QFileDialog
I used QFileDialog to browse and select a file.
Step 1
I browsed c:\test\files and selected xyz filde from that folder
Step2
Again when i need to browse for files. This time i want QFileDialog to point to my last visited folder (i.e., c:\test\files)
I know its is possible to do by saving the current visited directory and use QFileDialog.setDirectory to set the previous directory.
Is there any other option like savelast path browse, something like that....?
Is it possible...?
If YES how can i do it.
You can try using the saveState() and restoreState() methods in conjunction with QSettings, but this is just a variant of saving the last path even if probably it is a better method

Setting up an icon for start menu folder group in InnoSetup

To my surprise I did not find the solution how to set up an icon for the start menu application group folder laying ahead. I am looking for the automatic solution in InnoSetup script.
Thank you in advance.
Create the desktop.ini file with the content like this if you want to use the *.ico as a resource (where c:\somepath\icon.ico is path to your icon):
[.ShellClassInfo]
IconResource=c:\somepath\icon.ico,0
Or create the desktop.ini file with the content like this if you want to use the icon from the executable as a resource (where c:\somepath\program.exe is path to your executable):
[.ShellClassInfo]
IconResource=c:\somepath\program.exe,0
Save this desktop.ini file into the directory where you want to apply the icon. One very important note, you have to set to this newly created file attributes Hidden and System, otherwise it won't work!
So please check very carefully if the InnoSetup won't clear these attributes if you'll have the file included in your setup package while installing.

Resources