c# - Set that a program has to run at startup from an installer -


i've c# .net 4 application, i'm starting create installer.

the installed program works fine, customer want application start window(it's "always of top" toolbar them manage call).

i thought create "class installer", , in insert key in registry.

i've 2 problems:

first: how can find executable path? can change between installation. found somewhere application.executablepath, seems located application.window.forms think not compatible wpf

second: need insert key in registry of local machine. there way in windows installer specify user must have admin rights?

here code started:

registrykey rkapp = registry.localmachine.opensubkey("software\\microsoft\\windows\\currentversion\\run", true); rkapp.setvalue("cststart", ???); 

thank help!

edit: found can pass custom action data, :

/dir="[targetdir]\"

in customactiondata.

normally it's said can retrieve through

this.context.parameters["dir"]; 

but.... seems in installer class, this.context null :(

edit2: context null because doing in constructor, i'm doing in event this.afterinstall , context, seems contains var "assemblypath" contains path need.

my assumption you're working setup project here.....

one way - i'm not saying best easiest - following:

in "file system" tab, right click on "file system on target machine", "add special folder", "user's startup folder" , such folder appears on list. next, shortcut project output (by right clicking) , drag shortcut startup folder.

last of all, since want users, go deployment project properties , set "installallusers" true.

now, there caveat approach, in app not start when windows starts, when logs on. of project (a ui app) may ok.

if want go hacking registry @ creating custom action dll. can write pretty like, , @ end of install process setup program call dll can stuff. can pass things path of executable parameter dll (which pick installer dialog, not object). won't go detail there must loads on web this.

you should aware there finite amount of information can pass dll - might low 256 chars if memory serves. you'll ok path when start doing more....

as regards detecting whether user local admin, bit more tricky, if because custom action dll gets run @ end of installation rather @ start - write code find out groups current user in, chances you'd have blown before code run. don't believe - in microsoft setup project @ least - possible know this.


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -