1

I have a ClickOnce application and a simple c# launcher that starts the ClickOnce application by launching IE with the URL of the app. I would like to set an environment variable that can be read by the ClickOnce application. Is this possible? This is my code for the launcher app:

ProcessStartInfo pInfo = new ProcessStartInfo("iexplore.exe", "http://svr:8080/cotest.application"); Process appProc = new Process(); appProc.StartInfo = pInfo; appProc.StartInfo.EnvironmentVariables.Add("some_var", "some_val"); appProc.StartInfo.UseShellExecute = false; appProc.Start(); 

I realise that I'm setting the variable for iexplore, but I thought (hoped) the environment might be inherited by the ClickOnce app. What happens is that the ClickOnce app starts but if I list its environment, the variable "some_var" is not present.

Any ideas?

3
  • Don't know about env vars, but you could also pass such information via the query string. E.g. http://svr:8080/cotest.application?some_var=some_val. Commented Jun 8, 2016 at 13:37
  • @Christian.K Unfortunately in my case it has to be an environment variable, but this is good to know. Thanks! Commented Jun 8, 2016 at 14:44
  • I'm no expert here, but I wouldn't be surprised if it is just not possible to manipulate the environment for security reasons (let's say someone alters the PATH and thus allows to "inject" a DLL or something like that). Commented Jun 8, 2016 at 14:46

1 Answer 1

1

Probably you are going to face some security limitation by using ClickOnce when you are changing environmental variables for non user variables.

Please see below:

Edit environment variable in registry

I think you may need to either consider using other setup package methods (i.e. InstallShield) or change the way that you intract with Internet Explorer and pass parameters to your site.

If you provide your full requirements people might be able to help you with alternative solutions.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.