2

My customers run a c# bootstrap program remotely on windows 10 desktops.

There is one firm who's users all experience the same issue. No other firm reports the problem and we are unable to reproduce the issue in our test environment.

I can not determine the cause of the problem.

The problem is that each user is forced to start a C# program manually because the program fails to start automatically when the user logs in to his PC.

The current mechanism to auto-start the program is to provide a short cut in the Start-up folder during installation.

C:\Users\[Username]\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup

The C# program is just a bootstrap program that is used to launch a Java Swing UI so it can not be run as a Windows Service (as far as I know) because it produces an interactive display.

The program runs continuously unless it is explicitly killed by the user or he logs-off, the PC is rebooted, etc.

The error occurs when the bootstrap program tries to delete and copy an executable file during start-up.

My guess is that either the file is in use or the user doesn't have permission to delete the file.

The program is installed under the User's home directory (C:\Users\[Username])

The user's IT admin has confirmed that the user has full control and all permissions (except Special permissions) on the sub folders and executable.

The user is not an Admin user.

System.UnauthorizedAccessException: Access to the path 'C:\Users\username\UI\jre\bin\filename.exe' is denied.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.File.InternalDelete(String path, Boolean checkHost)
   at UI.Client.RetryDeleteFile(String filename) in Z:\Perforce\Head\main\src\dotnet\UIStartUp\UI\Client.cs:line 852
2019-04-02 06:59:05.SSS [ERROR] UI.Client:852: Not able to delete file (retrying): C:\Users\username\UI\jre\bin\username@company.com.exe: 

Looking for suggestions on how to pin-point and resolve this.

The IT Admin in charge of the User desktops is not very cooperative and is rightfully running out of patience as we have been shooting in the dark.

I suppose we can come up with an installation option to avoid deleting files but this would disable a feature by which we are able to remotely upgrade our software without going through the installation process.

Michael Starkie
  • 383
  • 3
  • 15
  • 1
    If it's just deleting that's the issue, you could possibly not delete the file in the bootstrap and instead delete from java. – MineR Apr 03 '19 at 14:22
  • It's actually the Java binary that is being deleted and copied. This way we can package and update the jre remotely. – Michael Starkie Apr 03 '19 at 14:44
  • After saying this "Don't want to just add code without knowing what the real issue is. This could potentially throw UnuathorizedAccessException as well." the question needs to be closed IMHO. No one can know what is the issue, and according the site rules even the questions without the case to reproduce should be closed, let alone with comment like this. – Ivan Ičin Apr 03 '19 at 15:20
  • There may be ways to pin-point the issue by adding diagnostic code that I am unaware of so I don't think it's impossible to discover what the issue is. – Michael Starkie Apr 03 '19 at 15:29
  • Then you should ask on how to collect the diagnostic code, it is quite a different question, you wouldn't get the answer below. – Ivan Ičin Apr 03 '19 at 15:49
  • "Looking for suggestions on how to pin-point and resolve this." – Michael Starkie Apr 03 '19 at 16:13

1 Answers1

0

You can try to set the code below before delete or after copy

File.SetAttributes(dest, FileAttributes.Normal);

e.g.

File.SetAttributes(dest, FileAttributes.Normal);
File.Copy(file, dest, true);

Referenced from Why is access to the path denied?

  • Don't want to just add code without knowing what the real issue is. This could potentially throw UnuathorizedAccessException as well. – Michael Starkie Apr 03 '19 at 14:54