I'm gonna sound like a broken record because I just suggested this in the "General" forum, but I think it's valid here.
If the user is currently logged in and I need to alter their HKCU keys or install something to their AppData, I use RunAsCurrentUser to execute a reg add or whatever.
http://software.bigfix.com/download/bes/util/RunAsCurrentUser-2.0.3.1.exe
So for instance, in my deployment, I needed to make sure that a file was copied in to the logged-in user's AppData folder. Within my Deploy-Application.ps1 I have this:
EDIT: There's not a lot out there on this application, so here's a quick link on use.
http://www-01.ibm.com/support/docview.wss?uid=swg21506033
If the user is currently logged in and I need to alter their HKCU keys or install something to their AppData, I use RunAsCurrentUser to execute a reg add or whatever.
http://software.bigfix.com/download/bes/util/RunAsCurrentUser-2.0.3.1.exe
So for instance, in my deployment, I needed to make sure that a file was copied in to the logged-in user's AppData folder. Within my Deploy-Application.ps1 I have this:
$CMD = 'Files\RunAsCurrentUser.exe'
$arg1 = '--w'
$arg2 = 'cmd.exe'
$arg3 = '/c'
$arg4 = 'xcopy'
$arg5 = 'Files\deployment.properties'
$arg6 = '%USERPROFILE%\AppData\LocalLow\Sun\Java\Deployment\'
$arg7 = '/y'
& $CMD $arg1 $arg2 $arg3 $arg4 $arg5 $arg6 $arg7
I know that looks silly but I was having a hard time calling it with Execute-Process for some reason. Anyway, I'm sure you see where you could plug in an uninstall script there. RunAsCurrentUser.exe is still being run as the SYSTEM account, and all the changes are being made to whoever is currently logged in to the computer. Pretty cool, eh?EDIT: There's not a lot out there on this application, so here's a quick link on use.
http://www-01.ibm.com/support/docview.wss?uid=swg21506033