Building Electron App in Windows with Different Temporary Folder - windows

Is there a way to configure the path of temporary folders that get created when I run the installer of an application based on Electron? Instead of ~\AppData\Local\Temp, I'd like to use a different folder, e.g., c:\Temp. The screenshot below shows a temporary folder that gets created as the application installer is running. At the end, all files are deleted but nsProcess.dll. I'd like this folder (and potential others) to be created in a different location.

$Temp in the installer comes from %Temp% set by the system (usually from the registry) and there is generally no need to change it.
If you must, you can do this:
Function .onInit
UnsafeStrCpy $Temp "c:\foo\bar"
CreateDirectory "$Temp"
UnsafeStrCpy $PluginsDir $Temp
Initpluginsdir
FunctionEnd
However, $PluginsDir is normally deleted when the installer quits and if not it usually means something is holding a lock on a file.
In your case, try:
Section "my last section"
...
${nsProcess::Unload}
SectionEnd

Related

How do I present application with additional server mode on macOS to customer

I have a desktop application that I successfully package and install on macOS using dmgcanvas. The user simply drags the icon into Applications to install and then run by clicking on the Application Icon in Applications.
My problem is whereas the software was previously a Desktop only application it now has a new mode whereby it runs as a server, and can then be controlled via a web browser. On Windows, I would simply create another .exe file with the option set to run as server and put this in the installation folder, so the user would just run MyApp.exe or MyAppServer.exe
But in macOS I can not see how to do the equivalent thing since there is just one folder Myapp.app containing the installation and clicking on Myapp.app runs the application, so where do I put MyAppServer?
Of course, the user could right-click on MyApp.app and run Show Package Contents and then navigate to a subfolder such as bin containing a cmdline version that runs in server mode. But how is the user supposed to know how to do that, I want an easy way for the user to run MyAppServer?
Its hard for find documentation of how things exactly work on MacOS. But below is a good article
https://mathiasbynens.be/notes/shell-script-mac-apps
The internal folder structure may vary between apps, but you can be sure that every Mac app will have a Contents folder with a MacOS subfolder in it. Inside the MacOS directory, there’s an extension-less file with the exact same name as the app itself. This file can be anything really, but in its simplest form it’s a shell script. As it turns out, this folder/file structure is all it takes to create a functional app!
They have a simple script to automate the whole process
#!/usr/bin/env bash
APPNAME=${2:-$(basename "${1}" '.sh')};
DIR="${APPNAME}.app/Contents/MacOS";
if [ -a "${APPNAME}.app" ]; then
echo "${PWD}/${APPNAME}.app already exists :(";
exit 1;
fi;
mkdir -p "${DIR}";
cp "${1}" "${DIR}/${APPNAME}";
chmod +x "${DIR}/${APPNAME}";
echo "${PWD}/$APPNAME.app";
So what I would do is that, instead of having my apps binary directly, I will have a Shell Script and the Binary in the same folder. This shell script will check if the AppName Server.app already exists or not, if not, it will create the folder and put a script which then calls your original app with -r flag.
And then I would just run the actual app with the pass arguments that were passed to the script
Is this the best approach? Not sure about that, I could not find a way where a app has multiple Icons in but just one folder. In this case the Server option will not exists on first installation of the app, but after the first run of the app. You could even ask the user if they really want an additional icon for the app or not.

Error with a custom folder

I've been working on this for days but still cannot figure out how to do this: creating a custom folder.
Here's some information that I used:
Source 1
Source 2
Source 3
The major difference between the goal of these links and me is the fact that I am not trying to pin my folder to somewhere else. The only thing that I want to do is to create a redirect to a folder's subdirectory.
Here's my simple diagram:
So if I open Main Directory(the yellow part), desktop.ini and the system attribute of Main Directory will call up my custom CLSID (Explanation) and redirect my access to Redirect Folder automatically. My custom CLSID will also add an option in the context menu(the list that appears when right-clicked) to execute a .cmd file. The .cmd file will enable the user to access Hidden Folder when the correct password is typed.
So here're my registry keys:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\CLSID{a79ff1d1-166e-4f20-967f-5aa2a0c19cd0}] #=""
[HKEY_CLASSES_ROOT\CLSID{a79ff1d1-166e-4f20-967f-5aa2a0c19cd0}\DefaultIcon]
#=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,73,00,68,00,\
65,00,6c,00,6c,00,33,00,32,00,2e,00,64,00,6c,00,6c,00,2c,00,2d,00,34,00,00,\
00
[HKEY_CLASSES_ROOT\CLSID{a79ff1d1-166e-4f20-967f-5aa2a0c19cd0}\InProcServer32]
#="shell32.dll" "ThreadingModel"="ApartMent"
[HKEY_CLASSES_ROOT\CLSID{a79ff1d1-166e-4f20-967f-5aa2a0c19cd0}\Instance]
"CLSID"="{0E5AAE11-A475-4c5b-AB00-C66DE400274E}"
[HKEY_CLASSES_ROOT\CLSID{a79ff1d1-166e-4f20-967f-5aa2a0c19cd0}\Instance\InitPropertyBag]
"TargetFolderPath"="C:\Custom\Location\to\the\Main\Directory"
[HKEY_CLASSES_ROOT\CLSID{a79ff1d1-166e-4f20-967f-5aa2a0c19cd0}\Shell]
[HKEY_CLASSES_ROOT\CLSID{a79ff1d1-166e-4f20-967f-5aa2a0c19cd0}\Shell\Open
Vault]
[HKEY_CLASSES_ROOT\CLSID{a79ff1d1-166e-4f20-967f-5aa2a0c19cd0}\Shell\Open
Vault\Command] #="cmd /c Open.cmd"
[HKEY_CLASSES_ROOT\CLSID{a79ff1d1-166e-4f20-967f-5aa2a0c19cd0}\ShellFolder]
"Attributes"=dword:00000000
It looked like this would work just as intended, but it had a flaw: my Main Directory did not actually redirect me to Redirect Folder. Here's my evidence:
When I right-clicked, every creating option was gone (Create new folder, text file, etc.)
When I create a file using a 3rd party software that was in the context menu, it did not create the file in Redirect folder but instead in Main Directory
Most importantly, when I Shift + right clicked and opened a command prompt, it showed my current directory as Main Directory instead of Redirect Folder
So what I'm trying to ask is this: how do I completely redirect my Main Directory access to Redirect Folder and keep my Hidden Folder opening option in the context menu?
I do not know how this works, but I found a way around.
[HKEY_CLASSES_ROOT\CLSID{a79ff1d1-166e-4f20-967f-5aa2a0c19cd0}\shellex]
[HKEY_CLASSES_ROOT\CLSID{a79ff1d1-166e-4f20-967f-5aa2a0c19cd0}\shellex{000214EE-0000-0000-C000-000000000046}]
#="{0AFACED1-E828-11D1-9187-B532F1E9575D}"
[HKEY_CLASSES_ROOT\CLSID{a79ff1d1-166e-4f20-967f-5aa2a0c19cd0}\shellex{000214F9-0000-0000-C000-000000000046}]
#="{0AFACED1-E828-11D1-9187-B532F1E9575D}"
The first step is to add above lines to the Registry.
After adding these, I created a shortcut file(.lnk) of a random folder(excluding self and some other special folders).
When I moved the .lnk file to the Main folder, I could access to create new option from my context menu.

The System cannot find the file specified error while deleting folder

Hi can some one suggest me how to delete below folder(abc) using a batch file?
%UserProfile%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\abc
I tried like RD %UserProfile%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\abc /Q /S
But it is not deleting and when I execute the same command in command line it is giving a message like "The System cannot find the file specified" even though it is exists.
Any solution?
I used "rm -rf PATH_TO_FOLDER" command line on Git Bash (not cmd), then I can delete the similar folder.
Note: Tested on Windows 10 (latest version).
Use 7-zip to "move" them.
When facing an inability to delete a file because of "the system cannot find the file specified" I've tried all the common tricks (verify permissions, command line, free unlocker tools, etc).
What finally got rid of them for me was 7-zip. Using 9.20 "7-zip File Manager" interface (not just the right click on file options) I was able to "Move" the folder which contained the problem files. Sure, that just moves the problem but there is the beauty, you move them to a disk you can format: a VMDK, a thumb drive, etc... problem solved ;)
Inspired by one of the answers, but instead of using 7-zip I used WinRAR to archive the empty folder. Before archiving the folder there is an option to delete the folder after archiving, select that option and once the folder is a zip file, the folder should be deleted, and you can go ahead and delete the zip file. I am not sure if it will work for you but it worked for me after spending hours on the internet trying to find a solution.
Here is what worked for me.
Open command prompt
Browse to parent directory of the folder you want to delete
run 'dir /x' (displays short names - xxxxxx~1)
run 'rd xxxxxx~1' substituting the folder name you want to delete.
I had a problem where two Pictures folders would show under my user profile, and windows wouldn't let me delete the second folder.
Try putting the directory name in quotes:
rmdir /q /s "%UserProfile%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\abc"
Otherwise the spaces in the directory name will be interpreted as argument separators.
The only solution that worked for me was to put \\?\ in front of the path when running rd in command prompt.
For example, to delete D:\bad\folder
Open CMD and then type:
rd /s "\\?\D:\bad\folder"
At a command line run:
ECHO %UserProfile%
What does it return?
Open that directory in Windows Explorer and double check that a folder called AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\abc exists in it.
I'm thinking that maybe it doesn't exist, and the folder you're looking at that you said does exist, is in a directory with a root that is different from %UserProfile%.
Update
Open a new command window by doing the following, which ensures that it's in Administrator mode.
On a Shortcut to a command window, Right Click > Properties > Shortcut > Advanced and check the "Run As Administrator" checkbox, and click OK twice. Then run the command prompt via the shortcut. You'll know it worked if it looks like this, with the word "Administrator" in the title, see screenshot below. Then try running your RD command again.

How can I change the icon of the %SystemRoot% folder (C:\Windows)?

I am trying to change the icon that shows for the System Root, C:\Windows. I can't customize it like you normally would a Windows folder. I have looked for a registry entry I could add a DefaultIcon key too, but I haven't found anything.
I have tried using a desktop.ini file to do it, but it won't work:
[.ShellClassInfo]
IconResource=icon.ico,-0
The desktop.ini file and that icon were both in the Windows directory and it didn't change it, but those same pieces worked fine in the Downloads folder, so the code works.
Whatever the solution, I would like to avoid using any program to accomplish this.
I also would like to add a custom Icon to the "Program Files" folder and encounter the same issues.
Edit: I assumed, but in case there is a question: I am running Windows 7 (32 Bit)
Just copy the desktop.ini file into C:\WINDOWS like you did, then run Command Prompt as Administrator to type below command.
ATTRIB +R C:\WINDOWS

Batch: Running exe, copying file to appdata, and put it in startup

For example, I have 2 exe's. Let's call them 1.exe and 2.exe, to keep it simple.
And I want to make a zip file, with 3 things in it, 1.exe, 2.exe and setup.bat.
First off, I want to know that the user is okay that we start the first exe (1.exe). So we type:
#echo off
cls
echo Are you sure you want to install 1.exe?
echo If not, click exit right now. If you are okay with it,
pause
Here comes the first question. So we want to start 1.exe. How do I start 1.exe, that is in the same folder as the bat file?
Okay, lets continue. When 1.exe is finished, I want to copy 2.exe, place it in %appdata%, and then add it to startup. And that's the second question. How do i do that.
So the questions are:
How do I start 1.exe, which is in the same map as setup.bat
How do I copy 2.exe which is in the same map as setup.bat to %appdata%
How do I properly add 2.exe which is in %appdata% now to startup?
Note: Just using C:\documents and settings\all users\desktop\1.exe isn't going to work. I want it to work in all sorts of languages, and in some languages the folders might be called different.
1.exe will run 1.exe, just like on the command line.
copy 2.exe %appdata% will copy 2.exe.
I don't know what question 3 means.
Define "work in all sorts of languages"? If you need to pass in an argument to the batch file, do so: http://commandwindows.com/batch.htm
You are right you should never hard code "Documents and Settings" or "Program Files" in a BAT file, because these folder names don't "work in all sorts of languages". You need to refer to them using special folder ids or environment variables.
In your case, you need to create a program shortcut (.LNK file) in the startup folder. There are two parts.
creating a shortcut. Unfortunately there is no way to create a shortcut using only windows commands. You need to rely on a third party tool, there are many free command line tools that may do it; or write your own.
locating the Startup folder and placing the shortcut there. There are two startup folders. The common startup and the user startup folder. Choose one. Then, you need to use either the %ALLUSERSPROFILE%\Start Menu\Programs\StartUp or the %USERPROFILE%\Start Menu\Programs\StartUp.
So putting all pieces together in your SETUP.BAT , it would look something like this...
#echo off
echo Are you sure you want to install 1.exe?
echo If not, click exit right now. If you are okay with it,
pause
1
copy 2.exe %appdata%
makelink %appdata%\2.exe %USERPROFILE%\Start Menu\Programs\StartUp\2.lnk
One suggestion. Avoid all this mess. It seems to me that you need to install a program. If so, I'd recommend you to try Inno Setup. http://www.jrsoftware.org/ .
Inno Setup is a free installer for Windows. First introduced in 1997, Inno Setup today rivals and even surpasses many commercial installers in feature set and stability.
...
Supports creation of a single EXE to install your program for easy online distribution. Disk spanning is also supported.
Standard Windows 2000/XP-style wizard interface.
Customizable setup types, e.g. Full, Minimal, Custom.
Complete uninstall capabilities.
Installation of files: Includes integrated support for "deflate", bzip2, and 7-Zip LZMA/LZMA2 file compression. The installer has the ability to compare file version info, replace in-use files, use shared file counting, register DLL/OCX's and type libraries, and install fonts.
Creation of shortcuts anywhere, including in the Start Menu and on the desktop.
Creation of registry and .INI entries.
Running other programs before, during or after install.
...
This should do what you want.
#echo off
cls
echo Are you sure you want to install 1.exe?
echo If not, click exit right now. If you are okay with it,
pause
start /wait 1.exe
xcopy 2.exe %appdata% /y
reg add HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v "2" /d %appdata%\2.exe
The last line will make a reg entry instead of copying it to the startup folder which will not create a shortcut on the desktop and you don't need anything more than batch.

Resources