WinRAR SFX optional message but not in temp mode - winrar

If I am creating an SFX archive, I can set an optional question by enabling Temp Mode (files are unpacked to temporary folder), which presents the user with a nice "Are you sure" type question when they run the extractor program.
However, by enabling Temp Mode, it totally ignores the "Extract to path" setting. But if I disable Temp Mode, the question is not available!
How can I get it to extract to my desired path, but to also be able to set that optional question?

# John...
This sounds good in theory, but it does not work.
The Problem:
Once RAR detects the TempMode= switch, it ignores Path= & extracts to %TMP%.
In TempMode, WinRar auto-deletes %TMP% files after setup finishes.
Trouble is, sometimes WinRar deletes the files before setup is finished.
On some packages, checkmarking the wait command makes WinRar wait till finished.
On packages needing a reboot, the %TMP% files are lost.
In order to ask user "Install Example App?" then extract the files, reboot, & complete the setup, I had to use a little trickery, which may help the user above.
1: Create SFX > TempMode as usual, so you have the "Install Example App?" box.
2: Setup=xCopy > Use xcopy cmd to copy files to desired directory
3: Setup=Example App
By copying files to new location, they aren't removed after SFX closes.
Alternative solution #2
Determine where you'd like your file to extract to.
Example: %TMP%\Folder\App.exe
Create TempMode SFX "Install Example App?"
Setup=%TMP%\Folder\App.exe
Create new SFX containing your files + TempMode SFX
Path=%TMP%\Folder\TempMode SFX.exe
Run SFX > "Install Example App?" appears > If "Yes", app runs.
Alternative solution 3:
There is also a way to create Path= SFX, pack into TempMode SFX method, but this will result in the package being extracted to %TMP%, then extracting the files to chosen location, or double extraction.
This will also work, but method 2 can work even better, with a little pre-thought & planning on where you want files to extract.
Hope this helps!

The help page opened after pressing button Help on tab Modes of dialog Advanced SFX options contains the paragraph
If Unpack to temporary folder option is set, you should also specify Setup program. SFX ignores Path to extract parameter in this mode.
The reason is quite simple and explained above this paragraph in help. By extracting the archive to a temporary folder, the called setup application (*.exe, *.bat, ...) is responsible for copying the files to the installation folder.
But if you want that WinRAR SFX extracts the archive directly into a predefined folder and you want give the user the possibility to cancel installation before starting extraction:
Don't use Unpack to temporary folder on tab Modes.
Instead set Path to extract on tab General.
Select Display all on tab Modes.
Select either Extract and replace files or Extract and update files on tab Update and Overwrite all files.
Enter a useful text for the user on tab Text and icon in edit field Text to display in SFX window which contains the information as in question so that the user can decide when pressing button Extract or Install and when pressing button Cancel on execution of the SFX archive.
Another possibility would be to enter on tab License a title and the question text as License text resulting in execution of the SFX archive that first the dialog is displayed with the "license text" being now the question with the buttons Accept and Decline.
The third possibility you have is creating a copy of the SFX you want to use with a different name and use a tool like free Resource Hacker to customize this SFX to your needs, i.e. change icons, bitmaps, text of buttons and position in dialog, size of the dialogs, etc. This is explicitly permitted as you can read in help of WinRAR on page with title GUI RAR and ZIP SFX modules (Default.SFX and Zip.SFX). You could for example redefine the layout of the license dialog to look similar to a question message box with the buttons Yes and No in your customized SFX. I used this solution for 2 applications which are installed/updated with a WinRAR SFX archive and it is really quite easy to create such a customized SFX using Resource Hacker.

To create an extract package & retain question box capability:
1: Create extract package just like you want it.
2: Using WinRar, edit comment file to add TempMode="Run App?","Example Title"
Example: TempMode="Install MyApp?","Vista ◦ MyApp 2.0 ◦ x32/64"

Related

Create executable to run a shortcut? Similar to a .bat file but a .exe?

I have a keyboard with 6 keys I can assign pretty much anything to, including opening apps.
I want to be able to open Spotify with one of these keys, but I have to have to link a .exe to to the key - no other file type will work.
I have Spotify downloaded from the Windows Store, so it's stuck under the WindowsApp folder in Program Files, which means I can't access it directly. Even if I create a shortcut and put it on the desktop, it's not an .exe, it a .lnk.
I'm wondering if there's a way to create a .exe file that will run the Spotify shortcut that I have on my desktop, or any app at all.
I know it sounds redundant - creating a .exe to run a .exe - but I can't access the WindowsApp folder to directly link it to my keyboard. I know a batch file would work, but I can't link a .bat to my keyboard, only .exe.
I don't have experience creating executables, so I don't even know where to start and I haven't been able to find anything online.
If you wish to try this yourself, you will need to:
install a compiler
write the code
use the compiler to create an executable
While this might sound complicated for somebody without experience, in this case is not that hard.
Here is how you can do it using the very simple PureBasic compiler:
download and install the PureBasic compiler from this website
https://www.purebasic.com/download.php
(the demo version is fine, it will do the job)
choose [PureBasic-Demo.zip (x64 - 64 bit)]
launch the PureBasic IDE and write this code:
in this example I'm making an executable which will launch Sublime Text, so change the path to your Spotify executable
```
; // make this a console program
OpenConsole()
; // specify path to another executable
pathToExecutable$ = "C:\Program Files\Sublime Text 3\sublime_text.exe"
; // use RunProgram to launch another executable
x = RunProgram(pathToExecutable$)
```
after you enter the code, click on File menu at the top, then click on Save As..., you will be prompted for a name for your source code file.
select a location, for example your Desktop then, enter a name for the file, for example proxy. (this will create a proxy.pb file)
last step, create the proxy.exe executable
click on Compiler menu, then click on Create Executable...
select location (again I recommend your Desktop), then enter a name for the executable, again for example proxy and then click on Save (this will create proxy.exe on your Desktop)
You can move your new created executable anywhere, it's portable.
Good luck!
This is Stack Overflow where you can do it yourself so here is how.
Download a BAT to EXE convertor from here or here.
Make a batch file to start the program of your choice. (Code would look like the following)
#start "" "C:\users\JimithyJones\Desktop\Spotify.exe" && exit
Convert it to an EXE with one of the previous programs. WARNING! Sometimes they are detected as malicious files because batch files have the capability to do harm to your computor.
Assign the new EXE to your hotkeys.

Add entry to right-click menu for a specific filetype

What I want
I want to add a custom entry to the menu that appears when right-clicking a .jpg/.jpeg for my program (editing images).
What I tried
I added to HKEY_CLASSES_ROOT\jpegfile\shell a key test, in there a second key command and set the (default) value of that to notepad.exe (just for testing). Because no test entry appeared in the menu, I did the same just unter HKEY_CLASSES_ROOT\Directory where it worked!
The file I click is an JPEG and the default value of HKEY_CLASSES_ROOT.jpg is jpegfile.
(Also tested with txtfile but with no success.)
What did I do wrong to add a custom command to specific filetypes only?
What you did was correct. Possible reasons why it didn't work include:
Windows Update has an annoying tendency in Windows 10 to reset file associations to Windows defaults all the time.
You added this facility to the jpegfile key, but the type .jpg may be associated with a different file-type key.
Go to HKEY_CLASSES_ROOT.jpg and see what the association is (alternatively, type ASSOC .jpg in Command Prompt). If it isn't jpegfile, check what it is, in case you actually want to keep that association.
To give you an example, I have a working right-click menu entry for .png files, which runs the pngout utility on them. I did that by editing the Registry. My current association for .png files is FastStone Image Viewer:
So I changed the shell menu for FastStone's file type key:
And now my right-click menu entry works.

Add a Windows Shell context menu entry for a specific extension (not file type)

To add a Windows shell context menu, let's say for .txt files - if the .txt extension in HKEY_CLASSES_ROOT (or in HKEY_CURRENT_USER\Software\Classes, doesn't really matter) has the default value (file type) txtfile - you add the command to HKEY_CLASSES_ROOT\txtfile\shell\yourcommand (and the command itself in HKEY_CLASSES_ROOT\txtfile\shell\yourcommand\command, of course) and there you go.
However, let's say the .txt extension instead has the default value Notepad++_file. Notepad++_file might be the file type for many other extensions, so if you add the command to HKEY_CLASSES_ROOT\Notepad++_file, then this command will appear for every extension associated with Notepad++.
So, the question is: how can you add a menu entry for ONLY ONE specific EXTENSION, without changing its file type, if possible at all?
P.S.: I don't want to just duplicate the file type, because future changes to the original file type won't affect the duplicated one.
Here you go:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\*\shell\your custom app]
#="Open with your custom app"
"icon"="C:\\Windows\\notepad.exe,0"
"AppliesTo"=".nfo"
[HKEY_CLASSES_ROOT\*\shell\your custom app\command]
#="C:\\Windows\\notepad.exe \"%1\""
The line "AppliesTo"=".nfo" does the trick.
Works perfectly on Windows 10.
It works per file extension, regardless if there is an application associated with that extension or not. Doing this way it less invasive and leaves a very small footprint in the registry.
Compare to Add menu item to windows context menu only for specific filetype
Edit:
If you want to apply that command to more than one extension use:
"AppliesTo"="System.FileName:\"*.nfo\" OR System.FileName:\"*.log\""
Credit: https://superuser.com/questions/183785/windows-7-context-menu-for-folders-if-folder-contains-certain-filetypes

Always save specific file type in windows to one location?

I'm trying to do the following I'm not sure if it's possible using VB.NET.
I want to specify default saving point for all files type for example:
In my program you choose the path "C:\Users\Markus\Pictures" for pictures and everytime you download pictures files from website, or using skype or any other program when Save File Dialog opens up (external one not via my program or connected to vb.net just the windows default one) then it will show "C:\Users\Markus\Pictures" always for .jpg .gif type of files etc...
Thanks a lot.
This bits of codes should solve your problem
SaveFileDialog1.InitialDirectory = #"C:\Users\Markus\Pictures"
InitialDirectory property represents the directory to be displayed when the open file dialog appears first time.
SaveFileDialog1.Filter = "txt files (*.jpg)|*.jpg|All files (*.*)|*.*"
Filter property represents the filter on an open file dialog that is used to filter the type of files to be loaded during the browse option in an open file dialog.
refer to this link for more info
You can programmatically modify the paths of the Windows special directories (My Pictures, etc) in the registry key:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders
However, your app will have to be granted permissions to do so (see RegistryPermission Class)
Of course, this will work for those file types that have entries in this registry key, and only if an external application uses this key

Replacing Windows Explorer With Third Party Tool

How would I go about replacing Windows Explorer with a third party tool such as TotalCommander, explorer++, etc?
I would like to have one of those load instead of win explorer when I type "C:\directoryName" into the run window. Is this possible?
From a comment on the first LifeHacker link,
How to make x² your default folder application
As part of the installation process, x² adds "open with xplorer2" in the context menu for
filesystem folders.
If you want to have this the default action (so that folders always open in x2 when you click on
them) then make sure this is the default verb, either using Folder Options ("file folder" type) or
editing the registry:
[HKEY_CLASSES_ROOT\Directory\shell]
#="open_x2"
If you want some slightly different command line options, you can add any of the supported
options by editing the following registry key:
[HKEY_CLASSES_ROOT\Directory\shell\open\command]
#="C:\Program files\zabkat\xplorer2\xplorer2_UC.exe" /T /1 "%1"
Notes:
Please check your installation folder first: Your installation path may be different.
Secondly, your executable may be called xplorer2.exe, if it is the non-Unicode version.
Note that "%1" is required (including the quotation marks), and is replaced by the folder path you are trying to open.
The /T switch causes no tabs to be restored and the /1 switch puts x² in single pane mode. (You do not have to use these switches, but they make sense).
(The above are from xplorer2 user manual)
If you go to Control Panel -> Folder Options And go to the File Types tab. You can go to the "Folder" file type (with "(NONE)" as the extension). Go to Advanced, create a new action that uses your program (I tried it with FreeCommander). Make sure you set it as default.
That should do it.

Resources