I am trying to set up one of the installers from the NSIS tutorials. The installer simply writes a text file to the desktop that says "Hello world!". The installer script reads as follows:
# declare name of installer file
Outfile "hello world.exe"
# open section
Section
# create a popup box, with an OK button and some text
MessageBox MB_OK "Now We are Creating Hello_world.txt at Desktop!"
/* open an output file called "Hello_world.txt",
on the desktop in write mode. This file does not need to exist
before script is compiled and run */
FileOpen $0 "$DESKTOP\Hello_world.txt" w
# write the string "hello world!" to the output file
FileWrite $0 "hello world!"
# close the file
FileClose $0
# Show Success message.
MessageBox MB_OK "Hello_world.txt has been created successfully at Desktop!"
# end the section
SectionEnd
The issue I encountered is that the file did not write to the desktop. After poking around for a few minutes I was able to find the file on the desktop of the Admin account on my computer instead of the current user. What do I need to do to configure NSIS to use the currently logged in user and not the Admin account?
Add RequestExecutionLevel User
to your script, this will tell Windows that you don't need UAC elevation.
When a non-admin user UAC elevates a new process, it will run as the admin user used in the UAC dialog.