VB6 Application on Windows 7 Cannot Access Mapped Drives

15,651

Solution 1

Adding this registry setting solved the problem for me: http://technet.microsoft.com/en-us/library/ee844140%28v=ws.10%29.aspx.

To work around this problem, configure the EnableLinkedConnections registry value. This value enables Windows Vista and Windows 7 to share network connections between the filtered access token and the full administrator access token for a member of the Administrators group. After you configure this registry value, LSA checks whether there is another access token that is associated with the current user session if a network resource is mapped to an access token. If LSA determines that there is a linked access token, it adds the network share to the linked location. To configure the EnableLinkedConnections registry value

  1. Click Start, type regedit in the Start programs and files box, and then press ENTER.

  2. Locate and then right-click the registry subkey HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System.

  3. Point to New, and then click DWORD Value.

  4. Type EnableLinkedConnections, and then press ENTER.

  5. Right-click EnableLinkedConnections, and then click Modify.

  6. In the Value data box, type 1, and then click OK.

  7. Exit Registry Editor, and then restart the computer.

Solution 2

I believe you are having trouble because casual drive mapping is per-user, and on a UAC system Administrators group users have two separate contexts (one for each token: SU & elevated).

There is such a thing as a system level drive mapping, which is one done under the System user (NT Authority\System). When you map a drive under this account, and map it persistently, all users can see and use the mapping (subject to the usual access rights for files there).

The normal way you do this is via Domain-level GPOs (Group Policy Objects), which means bribing your local box jockeys if in a corporate managed LAN environment.

One way to do this in a Workgroup machine is to map the letter as System via the AT command, from an elevated command prompt:

at 8:53 am "net use m: \\MediaShare\MyLibrary
    ThePW /user:MediaShare\TheUser /persistent:yes > nul"

There the remote server is MediaShare, user TheUser, password ThePW, and 8:53 AM is a minute or two in the future to avoid accidentally scheduling this for tomorrow.

But this fails on Vista and later due to Session 0 Isolation!

So... use the 3rd alternative at Run CMD.exe as Local System Account which is the same thing mentioned by ForcePush's reply to How to map a network drive to be used by a service.

I believe that's what you are after here.

Share:
15,651

Related videos on Youtube

Shane Brodie
Author by

Shane Brodie

Updated on June 04, 2022

Comments

  • Shane Brodie
    Shane Brodie about 2 years

    I have a VB6 application which links to several POS terminals from a Windows 7 32-bit machine. The POS terminals are mapped to the Windows 7 machine and I can access the POS terminals from the Windows 7 machine from Explorer or via the cmdline/shell.

    The application has been updated to ADO 2.8 and all other controls and components I no longer had source code for have been re-written. After a few annoying hiccups, I got the application to recompile on the Windows 7 computer without errors.

    Now come the problems. The VB6 application cannot see or navigate to any mapped drives! I have tried twiddling UAC settings; I have set the app to run in Windows XP SP3 mode; I have tried running as Administrator. None of these things (and many permutations of these) work.

    Any suggestions on how to make this work?

    • Gabe
      Gabe over 12 years
      What happens when you try to navigate to a mapped drive? What about a UNC path?
  • Shane Brodie
    Shane Brodie over 12 years
    Thank you for your input. In this case the drive mappings were initially instituted as local mappings by the logged-in user. I assumed that may be causing the issue and then had the network support people set the user up to configure the mappings to be set by either GPO as you suggest or via login script. In either case the result is the same. The logged in user can see and navigate to the mapped drives and has access to all files using Explorer or via the command-line. However, the VB6 application can neither "see" or access the shares at runtime.
  • Bob77
    Bob77 over 12 years
    Generally the login script only sets mappings for the unelevated user logging on. Exactly what credentials does the VB6 program run with? That same user? An elevated user? Some other user?
  • Shane Brodie
    Shane Brodie over 12 years
    The app runs with the credentials of the logged-in user. This is all that is required from an application standpoint.
  • Bob77
    Bob77 over 12 years
    I don't know what to tell you. I just tried mapping a share to Z: as a standard user, then ran a VB6 program and it had no problem with Z: either using Dir$() or Open/Line Input#/Close, Windows 7 SP1, 32-bit. Perhaps you have some completely different problem.