Old 19th January 2008, 16:42   #1
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
Uninstalling files from Vista VirtualStore

I have an application that writes save files to its own directory. Assuming the user installs this application to $programfiles, this will cause Windows Vista UAC to put those files into $APPDATA\Local\VirtualStore\Program Files\NameOfApplication.

At first I thought that calling 'delete $INSTDIR\save.file' as the user (not as admin) would make Windows delete the file from virtualstore. But since the following code does not work, apparently I was wrong in that assumption:
PHP Code:
!insertmacro UAC.CallFunctionAsUser un.DeleteSaves

Function un.DeleteSaves
  Delete 
/REBOOTOK "$INSTDIR\record.save"
FunctionEnd 
My question now is, is there a way to tell windows to delete the VirtualStore version of a file, instead of the file that the path would normally point to? (Note that in my case record.save only exists in VirtualStore and it still doesn't get deleted.) Or could NSIS be made to have a variable $VIRTUALINSTDIR that points to the instdir inside virtualstore?

I could of course get $INSTDIR and do a number of loops to cut out the xxx part from "C:\Program Files\xxx" and put it into "$APPDATA\Local\VirtualStore\Program Files\xxx", but that seems like the long way around to me.
MSG is offline   Reply With Quote
Old 19th January 2008, 17:25   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,442
http://forums.microsoft.com/MSDN/Sho...51420&SiteID=1

Doing things "as the user" with the UAC plugin does not help, if you use RequestExecutionLevel=anything, VirtualStore/file&folder redirection gets disabled AFAIK

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 19th January 2008, 17:55   #3
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
Paste from the channel, because Anders gave a rather interesting solution:

<Message> I see. So I'm pretty much stuck with deleting the files manually?
<Anders> fix your app?
<Message> heh, it's not mine
<Anders> if you make a little program/nsis app that does not have a manifest, you could exec it in the uninstaller, it would figure out the virtual store path and save it in HKCU, then read that back and delete the stuff (or that app could do the deletion)

My own solution is the 'long way around', which didn't turn out so long after all:
code:
Function un.DeleteSaves
Delete /REBOOTOK "$INSTDIR\record.save"
StrCpy $2 $INSTDIR "" 3
Delete /REBOOTOK "$LOCALAPPDATA\VirtualStore\$2\record.save"
#And then a small loop to delete the empty subdir(s).
FunctionEnd

MSG is offline   Reply With Quote
Old 20th January 2008, 00:47   #4
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,442
Just note that $instdir might not start with c:\, could be a UNC path: \\server\share\programfiles

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump