Mapped Drives and Run As Administrator issue
#1
Just ran into a little oops.

Writing a small backup utility to copy files from a mapped drive to a USB Thumb Drive.
I initially couldn't work out why it was silently failing with "Compile and Execute" 

I tried running the executable from Windows Explorer and it worked.

Then it dawned on me Smile:
I have PBEdit and PBWin set to "run as Administrator' to avoid the known issues with occasional slow compilation and/or compiler fails.
"Administrator " didn't have the drive mapping.

My solution:

Code:
      dwDrives = GetLogicalDrives
      IF BIT(dwDrives,25) = 0 THEN ' Drive Z not available
      ? "Cannot access source drive Z:\." & $LF & $LF & "You must run this application as a user with drive Z:\ mapped!" & $LF & $LF &  _
        "Note that the backup will fail if you run ""as administrator"" rather than as a normal user who has Z:\ mapped",%MB_ICONERROR,"Backup To USB Failed"
      EXIT FUNCTION
  END IF
Reply
#2
Stuart, I think this MS article fixes the problem of a network share in one context (elevated/normal) not appearing in the other context.

https://learn.microsoft.com/en-us/troubl...ed-command
Reply
#3
(01-29-2025, 03:50 PM)Raymond Leech Wrote: Stuart, I think this MS article fixes the problem of a network share in one context (elevated/normal) not appearing in the other context.

https://learn.microsoft.com/en-us/troubl...ed-command

Yes, it does in certain situations, but those  solutions are not applicable in the use case of the utility I was developing (for users on workstations in a network I have no control over).
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)