Aznarepse
Aznarepse

Reputation: 71

Installer launch application after install but cannot access network drives

I am distributing a desktop application with Windows Installer. In the commit, there is a custom action that launches the just installed application. It seems to run well but the started application cannot see the network drives that are mapped... If I exit the app and start it from the start menu, the app can see the network drives without problem. This app needs to read from the network...

Here is the code I use in the commit action:

ProcessStartInfo^ proc = gcnew ProcessStartInfo();
proc->UseShellExecute = true;
proc->FileName=mytargetdir + "program.exe";
try
{

    Process::Start(proc);

}
catch(Exception^ e)
{
    // Do nothing and return directly ...
}

I am assuming that I need to provide the current user credentials to the process but I cannot know them a priory. I can get the current user and domain with Environment but what about the password...?

how to launch the app with access to the network?

Upvotes: 0

Views: 130

Answers (1)

Christopher Painter
Christopher Painter

Reputation: 55581

Being scheduled in the commit execution it was probably launched as SYSTEM which doesn't have the same permissions as the user who launched the install. A better design is to have a checkbox on the completed dialog asking the user if they would like to launch the application and do so when checked and the user clicks close. This way it's launching from the UI sequence as the user.

You don't mention which tool you are using but I'm going to guess it's that horrible tool that Microsoft killed in VS2012 that thousands of people are complaining about on UserVoice to bring it back. None of them understand problems like the one you are facing now that caused Microsoft to kill it.

You can find them over here (Visual Studio Installer > How To Launch App at End of Installer) answering your question but despite the high vote count, it is wrong.

Upvotes: 1

Related Questions