9

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?

Notts90
  • 254
  • 2
  • 20
Shane Brodie
  • 117
  • 1
  • 1
  • 8
  • How do you set it to run in Windows XP SP3 mode? What happens when it *doesn't* run in that mode? – Gabe Jan 11 '12 at 01:26
  • You set it to run in compatibility mode, setting it to use Windows XP SP3 as the compatibility mode. This is done by right-clicking the link and using Properties. In practice, there is no difference when I ran it using this compatibility mode. – Shane Brodie Jan 11 '12 at 01:45
  • 1
    What happens when you try to navigate to a mapped drive? What about a UNC path? – Gabe Jan 11 '12 at 01:58
  • Within the VB6 application, drive lists for example, the mapped drives are not listed. Trying to access a MS Access database via ADO results in file not found errors. Haven't tried UNC path with a VB6 application (haven't worked much with VB6 in the last 5+ years ... seem to remember patchy UNC support ... but I could be wrong). I have worked with VB since VB 3 and Win 3.11, but have worked almost exclusively with VB.Net for the last 8 years – Shane Brodie Jan 11 '12 at 03:32
  • When you talk about "navigating", I'm assuming you're talking about a File Open dialog or somesuch. If that's not what you're using, try mapped drives and UNC paths with a common file dialog opened from your VB6 app. – Gabe Jan 11 '12 at 04:23
  • When you say the VB6 app cannot see any mapped drives - what is the error? or are you using a drivelistbox control and it is not showing up in that? – Matt Wilko Jan 11 '12 at 10:07

5 Answers5

11

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.

Motomotes
  • 4,111
  • 1
  • 25
  • 24
  • This worked for me, specifically for the Universal USB Installer http://www.pendrivelinux.com/universal-usb-installer-easy-as-1-2-3. – Andrew Keeton Aug 02 '15 at 23:56
5

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.

Community
  • 1
  • 1
Bob77
  • 13,167
  • 1
  • 29
  • 37
  • 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. – Shane Brodie Jan 11 '12 at 16:34
  • 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? – Bob77 Jan 11 '12 at 18:16
  • The app runs with the credentials of the logged-in user. This is all that is required from an application standpoint. – Shane Brodie Jan 12 '12 at 14:25
  • 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. – Bob77 Jan 12 '12 at 23:09
0

don't know if you ever figured this one out but for me it was the ChDir command (even with the registry fix above).

I had in my code

ChDir "P:\Temp\VidCap\Cam1\" 'I almost never use ChDir Open "list.txt" For Output As #1

and all the VB6 inbuilt file commands looked straight though any operations, no errors, no nothing. I solved it by explicitly having the path, (in my code it was in a string but you could have it explicitly):

dd = "P:\Temp\VidCap\Cam1\" Open dd & "list.txt" For Output As #1 works as expected.

hope this helps

H

hendy
  • 1
0

Try this:

Open command prompt as administrator, and type this in:

net use Z: \\IP Address\share /user:you passwd /persistent:Yes

Change "IP Address", the "share" name, and your username and password as needed.

Here's a screenshot

The author of this is howtogeek (source).

Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77
0

I had same problem. VB6 kept crashing when trying to access USB and mapped drives using the Commondialog method, even though the drives and files were all accessible OK via Explorer. Problem is the drives were not set as shared.

Solved by selecting the connected USB drive in explorer and then right click to

  1. select Properties.
  2. Select Sharing Tab
  3. Select Advanced Sharing
  4. Set the sharing and user rights as needed. May need to have local admin rights.