简体   繁体   English

Windows 7 上的 VB6 应用程序无法访问映射驱动器

[英]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.我有一个 VB6 应用程序,它从 Windows 7 32 位机器链接到多个 POS 终端。 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. POS 终端映射到 Windows 7 机器,我可以从 Windows 7 机器从资源管理器或通过 cmdline/shell 访问 POS 终端。

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.该应用程序已更新到 ADO 2.8,并且我不再拥有源代码的所有其他控件和组件都已重新编写。 After a few annoying hiccups, I got the application to recompile on the Windows 7 computer without errors.经过几次烦人的小问题后,我让应用程序在 Windows 7 计算机上重新编译,没有错误。

Now come the problems.现在问题来了。 The VB6 application cannot see or navigate to any mapped drives! VB6 应用程序无法看到或导航到任何映射驱动器! I have tried twiddling UAC settings;我尝试过调整 UAC 设置; I have set the app to run in Windows XP SP3 mode;我已将应用程序设置为在 Windows XP SP3 模式下运行; I have tried running as Administrator.我试过以管理员身份运行。 None of these things (and many permutations of these) work.这些东西(以及这些东西的许多排列)都不起作用。

Any suggestions on how to make this work?关于如何进行这项工作的任何建议?

Adding this registry setting solved the problem for me: http://technet.microsoft.com/en-us/library/ee844140%28v=ws.10%29.aspx .添加此注册表设置为我解决了这个问题: http : //technet.microsoft.com/en-us/library/ee844140%28v=ws.10%29.aspx

To work around this problem, configure the EnableLinkedConnections registry value.要变通解决此问题,请配置 EnableLinkedConnections 注册表值。 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.此值使 Windows Vista 和 Windows 7 能够在过滤的访问令牌和管理员组成员的完全管理员访问令牌之间共享网络连接。 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.配置此注册表值后,如果网络资源映射到访问令牌,LSA 将检查是否存在与当前用户会话相关联的另一个访问令牌。 If LSA determines that there is a linked access token, it adds the network share to the linked location.如果 LSA 确定存在链接的访问令牌,则会将网络共享添加到链接位置。 To configure the EnableLinkedConnections registry value配置 EnableLinkedConnections 注册表值

  1. Click Start, type regedit in the Start programs and files box, and then press ENTER.单击“开始”,在“启动程序和文件”框中键入 regedit,然后按 Enter。

  2. Locate and then right-click the registry subkey HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System.找到并右键单击注册表子项 HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System。

  3. Point to New, and then click DWORD Value.指向新建,然后单击 DWORD 值。

  4. Type EnableLinkedConnections, and then press ENTER.键入 EnableLinkedConnections,然后按 Enter。

  5. Right-click EnableLinkedConnections, and then click Modify.右键单击 EnableLinkedConnections,然后单击修改。

  6. In the Value data box, type 1, and then click OK.在数值数据框中,键入 1,然后单击确定。

  7. Exit Registry Editor, and then restart the computer.退出注册表编辑器,然后重新启动计算机。

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).我相信您遇到了麻烦,因为临时驱动器映射是针对每个用户的,并且在 UAC 系统上,管理员组用户有两个单独的上下文(每个令牌一个:SU 和提升)。

There is such a thing as a system level drive mapping, which is one done under the System user (NT Authority\\System).有一种系统级驱动器映射之类的东西,它是在系统用户(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.执行此操作的常规方法是通过域级 GPO(组策略对象),这意味着如果在公司管理的 LAN 环境中,贿赂您的本地接线员。

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 命令从提升的命令提示符将字母映射为系统:

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.远程服务器是 MediaShare,用户 TheUser,密码 ThePW,并且 8:53 AM 是未来一两分钟,以避免意外安排明天。

But this fails on Vista and later due to Session 0 Isolation!但是由于会话 0 隔离,这在 Vista 和更高版本上失败了!

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 .所以...使用Run CMD.exe 作为本地系统帐户的第三个替代方案,这与 ForcePush 对如何映射要由服务使用的网络驱动器的回复中提到的相同。

I believe that's what you are after here.我相信这就是你在这里所追求的。

don't know if you ever figured this one out but for me it was the ChDir command (even with the registry fix above).不知道你有没有想过这个,但对我来说这是 ChDir 命令(即使使用上面的注册表修复)。

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.并且所有 VB6 内置文件命令通过任何操作看起来都很直接,没有错误,没有任何内容。 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. dd = "P:\\Temp\\VidCap\\Cam1\\" Open dd & "list.txt" For Output As #1按预期工作。

hope this helps希望这可以帮助

H H

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.根据需要更改“IP 地址”、“共享”名称以及您的用户名和密码。

这是屏幕截图

The author of this is howtogeek ( source ).这篇文章的作者是howtogeek( 来源)。

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.尝试使用 Commondialog 方法访问 USB 和映射驱动器时,VB6 不断崩溃,即使驱动器和文件都可以通过资源管理器正常访问。 Problem is the drives were not set as shared.问题是驱动器未设置为共享。

Solved by selecting the connected USB drive in explorer and then right click to通过在资源管理器中选择连接的 USB 驱动器然后右键单击来解决

  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.可能需要具有本地管理员权限。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM