views:

295

answers:

4

I've got a web setup project with a custom screen in it that asks for a machine name. Is there anyway to prepopulate this field with the current machines name?

For the case that I need it for just including "Localhost" does not meet my requirements.

"Environment.MachineName" will return the machine name within a code block which would be fine if I was needing it in a custom action. But it seems custom actions don't excecute until after you go through the installation wizard... So I cant actually use it. Anyway let me know what you think.

+1  A: 

I'm not sure if you have access to code while the web setup project is running. If so, you could try the static "Environment.MachineName" property.

Andy White
But how would you assign that to the value to the msi property in my installation? Thats where I'm stuck.
Shane Kenney
Yeah, that's what I'm not sure about... sorry. :( I had actually deleted this answer right after I wrote it, but decided to undelete just for the heck of it.
Andy White
A: 

System.Environment.MachineName

Chathuranga Chandrasekara
A: 

Do you have access to environment variables? You could evaluate %COMPUTERNAME%.

lc
yeah I did give that a go but with no luck. Thanks anyway
Shane Kenney
+2  A: 

From my limited research, it doesn't look like the simple Web Setup Project will be enough for you to do what you want. I would suggest any of the following, depending on how important this is to your project:

  • Just use a default of LOCALHOST
  • Leave the default blank and use the dialog text to tell the user how to retrieve the machine name
  • Don't ask the user and make the settings later w/ a post-install exe/script that has access to environment variables
  • Use a different (read: more robust) installer

I would suggest the last one of course, but if you don't need really need this feature that bad, go with one of the other options that is acceptable enough in your situation.

Mufasa
Thanks for the response. What I ended up going for was to use LOCALHOST as a default value then, in a custom action in the installer replace LOCALHOST with the actual machine name using System.Environment.MachineName. It wasn't the most desirable result but like you said, the web setup project isn't exactly very robust and I probably would have needed to use a different installer if I had to pursue it any further.
Shane Kenney