Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VB6 Application on Windows 7 Cannot Access Mapped Drives

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?

like image 859
Shane Brodie Avatar asked Jan 11 '12 01:01

Shane Brodie


2 Answers

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.

like image 150
Motes Avatar answered Nov 13 '22 17:11

Motes


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.

like image 5
Bob77 Avatar answered Nov 13 '22 19:11

Bob77