1

I am trying to create a Windows installer for a VB.net program in Visual Studio 2022. The program creates an input file for a separate processing exe, called via shell(), then reads/parses the output file. I have been using the c:\programdata\ folder as a working folder for the input/output folders, which functioned great until I actually installed the program. Now I am getting a permissions error.

I am using the Setup Project extension in VS2022 if that makes a difference.

Open to suggestions, I am pretty 'fish out of water' when it comes to Windows.

Program functions as expected when running from inside VS2022 or if I copy the bin folder to a different location or computer.

Program fails after installation with "Access to the path 'C:\ProgramData...' is denied."

2
  • Did you use "Add Special Folder" -> "User's Application Data Folder" for the location or did you hard-code "c:\programdata\"? The former should work. Commented Sep 11, 2024 at 16:52
  • I used the "Add Special Folder" in the installer with the hard-link then hard-linked the code. I see the "User's Application Data Folder" option. Is there a way to soft-link to this location in the code? Commented Sep 11, 2024 at 17:35

2 Answers 2

0

You need to determine the correct path in the program at run-time, which you can do using the Environment.GetFolderPath Method. For example:

Dim dir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "lowriderdog37").

It's a good idea to use your own subdirectory to keep things tidy and organized.

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

7 Comments

I came to realize that the Environment.GetFolderPath Method worked when running the program in VS. After creating/using a MSI installler, the files are no longer written. I am guessing there is a permission VS has that the stand-alone (installed) version does not?
Which files are no longer written? The files that the installer should create, or the files that your program should be writing to?
The installer creates its files as expected. When running the installed program, the temporary input/output files are not written in the environmental folder. In my case, using the recommendation above, was c:\Users\me\AppData\Roaming. I tried with and without a subfolder, it didn't make a difference.
@lowriderdog37 Is there an error message? (If the code ignores exceptions by using an empty Catch, it would be better to record the exception instead of ignoring it, just in case that's what is happening.) Or is the file being written somewhere else unexpectedly? A search of the entire drive for the filename should help with finding out if that has happened.
It does throw an exception but doesn't tell me exactly where in the code. I am trying to figure out a way to capture the error. It is saying "-----" cannot be converted to integer, which makes sense but I need to figure out why and where. The main command of the program is called via shell() but directing the output to a file, nor pause commands are working. More to come...
|
0

You need administrative access by default to change files content inside "Program Data" which is special folder by windows vista and above.

When u run application within Visual Studio, it will run ok.

To solve the problem, I have changed the folder permissions to my data folder inside the 'Program Data' folder.

My problem solved.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.