Problem with program after installation proces


  • Hi,

    I compiled my window forms application and it works good from Visual Studio or exe from Debug directory, but after creating setup installation program and open it after it on my PC not everything works ok. How can I find the problem ? Installation needs admin rights maybe here is some difference ?

    My exe file from Debug also works on the other mashine, but installation process fail something.

    I use some external exe program from .bat file inside my source code and I noticed that problem occured in some on them. 

    Any idea how to find the solution ?



    Thursday, December 7, 2017 4:35 PM

All replies

  • I use some external exe program from .bat file inside my source code and I noticed that problem occured in some on them. 

    Not sure what you mean ... perhaps you should show the code you're using.

    ~~Bonnie DeWitt [C# MVP]

    Thursday, December 7, 2017 4:43 PM
  • For example:



    var proc = new Process();

                    proc.StartInfo.FileName = "fw.bat";

                    proc.StartInfo.UseShellExecute = false;
                    proc.StartInfo.RedirectStandardOutput = true;
                    proc.StartInfo.CreateNoWindow = true;


                    string path = @"fw.txt";
                    if (File.Exists(path))


    and inside fw.bat

    pslist -accepteula > fw.txt

    Thursday, December 7, 2017 4:48 PM
  • It probably has something to do with the path to the files. If your files are where your EXE is, you should use get the path like this:

    string path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);

    ~~Bonnie DeWitt [C# MVP]

    Thursday, December 7, 2017 5:03 PM
  • Yes, I have everything inside one dir, I will check later when I back.
    Thursday, December 7, 2017 5:07 PM
  • Another thing to check is to make sure that your files are actually copied to the debug or release folders when you build your solution (because files added to a project don't automatically get copied). To do this, in the Solution Explorer, go the file's Properties and make sure that the "Copy to Output Directory" is set to "Copy Always".

    ~~Bonnie DeWitt [C# MVP]

    Thursday, December 7, 2017 5:51 PM
  • Is it path to ... ? Where to use it ?

    I set path to specific file I need to use. Hmm.

    Thursday, December 7, 2017 9:32 PM
  • The code you showed didn't have a path, only a filename. That means that you expect the files to be in the same path where the EXE is (which is what the GetExecutingAssembly().Location will give you). If that's the case, then you shouldn't have a problem finding the file. Unless, as I mentioned in the my next reply, you haven't got the files set to "Copy Always".

    But, you also didn't say (and perhaps I should have asked) what exactly is the problem? You just said it didn't work ... does that mean it throws an exception? What isn't working and how do you know it's not working? Are you not getting results you expect to get? And what are those results?

    ~~Bonnie DeWitt [C# MVP]

    Thursday, December 7, 2017 10:12 PM
  • Hello grzybek7,

    but after creating setup installation program and open it after it on my PC not everything works ok

    And also please provide the details about creating setup installation program. I think this is important information for us.

    Best regards,

    Neil Hu

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Friday, December 8, 2017 7:28 AM
  • In my VS 2017 community I can't see "Copy to Output Directory" in file properties.

    Result of my program after installation is that some gathering data is not showing. Program test network connections and just gather some information from Windows system.

    Looks like my external e.x. "pslist.exe" ( insode .bat file )  doesn't run at all. Not throw any exception.

    To create my setup file I added files from Debug dir to Application Folder ( those tools like pslist and .bat files ) add shortcuts and  Standard/Basic  Outputs and thats all.



    Friday, December 8, 2017 10:01 AM
  • In Visual Studio, you've added a .bat file to your project from the Solution Explorer, correct? You've also added other text files to your project? But, in the Solution Explorer, when you right-click on one of those files, and choose Properties, you're saying that you don't see "Copy to Output Directory" in those Properties? 

    If all of your files are showing up in your installation directory, the above question doesn't matter (but, something's not right if you don't have "Copy to Output Directory"). It makes it easier to be sure you get all your files for your Installation program. What Installer are you using?

    One more set of questions ... what does your .bat file do (is it something that will need Admin permissions)? Where are you installing it ... In "Program Files"? That would be a permissions issue if you're writing to a file in that directory. If you install in Program Files, I believe that you should expect your data files to go into "ProgramData" or under "Users". All are "special folders" that your Installer should allow you to specify (something like Install Shield does ... but you haven't yet said which one you're using).  I know practically nothing about Installers, so I can't be more specific than that.

    Here's something you can try, that will verify if it's a permissions issue or not. If you have an external, USB or SDCard drive, try installing to that drive instead of on the C drive. You will have no permissions problems there. If you don't, you can try installing to your C drive, but to a new folder directly under the C root ... or anyplace other than the "Program Files" folder!!! 

    See if that solves the problem of your stuff not running.

    ~~Bonnie DeWitt [C# MVP]

    Friday, December 8, 2017 3:17 PM
  • Hi Bonnie,

    Thanks for help, it was permission issue. After installation program directly in C: drive it works good !

    So in "Program Files" I'd need run my program as admin rights although none of my exe tools need special priviligies.

    For me now it is not a big problem, but is it any sollution for it ?

    Best Regards,


    Saturday, December 9, 2017 10:08 AM
  • Hi Michal,

    You can make use of the SpecialFolder enums in your Application for accessing data files. For example:

    string path = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
    string path = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);

    You'd obviously create a folder under those paths int which you'd put your Application's data. Play around with the SpecialFolder if you'd like to see what else there is, but the two I mentioned are the more likely folders in which to place your data.

    As far as your Installer program goes, I would suspect that different Installers have similar SpecialFolder-like syntax in their settings.

    ~~Bonnie DeWitt [C# MVP]

    Saturday, December 9, 2017 5:22 PM