1

I want to check for a file and copy it over to another directory if it exists. Unfortunately, the file exists in the AppData folder.

CheckFile:
         !define INSTDIR_DATA "$APPDATA\Local\VirtualStore\Program Files\SomeFolder"
         IfFileExists INSTDIR_DATA\SettingsFile.ini CopyOver NotHere

I get into this section with no problem, but then it can't seem to find the file despite explicitly making sure it exists. Am I missing something? It should be noted I do want this directory searched via the current user directory, so setting it to all users is not needed.

Rajada
  • 37
  • 1
  • 8

1 Answers1

3

NSIS has a $LocalAppData constant:

DetailPrint $AppData
DetailPrint $LocalAppdata

on my system this prints:

C:\Users\Anders\AppData\Roaming
C:\Users\Anders\AppData\Local

$AppData is not actually the AppData "root" but the roaming part of it.

If you have the RequestExecutionLevel attribute in your script then this will affect how Windows deals with file-system redirection and the VirtualStore is a part of that.

Anders
  • 97,548
  • 12
  • 110
  • 164
  • So, this helps, but still doesn't work properly. Is defining this as "$LocalAppdata\VirtualStore\Program Files\Atari\Nerf\System" correct then? I don't currently have the execution level explicitly set, should I be attempting to run this function with administrative privileges? How exactly will it affect finding/copying a file in the VirtualStore? – Rajada Jan 07 '15 at 09:00
  • The syntax for using a define is ${name} so I hope your real code uses IfFileExists "${INSTDIR_DATA}\...". The execution level should not really affect finding files in the VirtualStore but if you don't set it and you are not elevated you will not be able to copy from it to $ProgramFiles ( http://support.microsoft.com/kb/927387#MT3 ). If you still cannot get it to work you should try Process Monitor from Microsoft/Sysinternals to see what is wrong with the path you are using... – Anders Jan 07 '15 at 14:47
  • Oh, I would overlook something like that. Thanks! – Rajada Jan 07 '15 at 19:31
  • @Anders: while searching for a list of NSIS constants I noticed that the Norton Security browser plugin blocks all nsis.sourceforge.io pages, as well as nsis.sourceforge.net, and marks them as dangerous. Is there anything you can do about that? – djvg Nov 12 '19 at 10:32
  • @djvg No, you should file a report with them and then uninstall Norton. – Anders Nov 12 '19 at 13:24
  • Uninstall Norton. Good idea. – djvg Nov 12 '19 at 13:45