skip to Main Content

I am testing one of our legacy programs in an Azure VM. I have SQL Studio and SDK installed to get BCP. The program is attempting to use Directory.GetFiles("C:\Program FilesMicrosoft SQL Server", "bcp.exe", SearchOption. AllDirectories) to get the path to the exe and start it using ProcessStartInfo. However, it is not returning any files, even though I can see BCP in one of the subdirectories of the folder in explorer. I’m assuming this is some Azure permission issue or Windows access issue, since the program is working locally on my machine. Does anyone have any insight or tips on how to resolve this?

2

Answers


  1. Your problem could indeed be related to the permissions on the Azure VM, especially since your program works correctly on your local machine (unless, as commented, it is a typo, with used instead of \).
    In Azure, applications often run under a restricted user account by default, which may not have access to certain directories. It could be a guest account.

    Applications running as a standard user or under a restricted service account might not have read access to the "C:Program Files" directory and its subdirectories. The "C:Program Files" directory is considered a system directory and has more restricted access to enhance system security.

    By default, the built-in "Administrators" group and the "SYSTEM" account have full control over this directory, while the built-in "Users" group has read and execute permissions.
    If an application is running under a user account that is not part of the "Administrators" or "Users" groups, or if the directory’s permissions have been changed from their defaults, the application might not be able to read the contents of this directory.
    You might need to double-check the directory’s security settings to confirm that the "Users" group has the expected permissions.

    You can try and run your application with elevated permissions (you would typically right-click on the executable and select "Run as administrator"), just to confirm the permission issue.

    You can also try a simple Powershell command, to see if you have the same issue:

    Get-ChildItem -Path 'C:Program FilesMicrosoft SQL Server' -Recurse -Include 'bcp.exe' -File | Select-Object FullName
    
    Login or Signup to reply.
  2. Have you compared the text "Directory.GetFiles("C:Program FilesMicrosoft SQL Server", "bcp.exe", SearchOption. AllDirectories)" with what you have on your local machine?

    Have you tried debugging messages / logging to see possible issues?

    Have you looked at the permissions of the directory / file bcp.exe and compared to the user executing your program?

    Just providing some thoughtful input. It would possibly be more helpful if you could provide the context around this command, is it possible that it could fail silently before even executing due to something seemingly unrelated?

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search