Windows系统中“网络位置”的注册表路径在哪里?

匿名
2022-12-02T15:15:14+00:00

我和几个同学需要为教室的电脑添加ftp位置,手动添加比较麻烦,我们希望写一个程序,通过注册表直接添加网络位置。我们已经能够修改注册表,但是我们不知道哪些是需要操作的。(或者可以给我们提供一个其他的解决方案)

我们尝试过类似这种的注册表添加,但是无法使用资源管理器打开ftp,因此我们更希望直接修改网络位置的注册表。(像截图中的localhost那个)

在中文和英文搜索中我们没有发现类似的解决方案。

系统:win7 64位或win10 64位

Windows 家庭版 | 以前的 Windows 版本 | 文件、文件夹和存储

锁定的问题。 此问题已从 Microsoft 支持社区迁移。 你可投票决定它是否有用,但不能添加评论或回复,也不能关注问题。

0 个注释 无注释

1 个答案

排序依据: 非常有帮助
  1. 匿名
    2022-12-03T13:43:37+00:00

    您好,

    网络路径不存在注册表中,它存在%AppData%\Microsoft\Windows\Network Shortcuts文件夹

    里面会有desktop.ini和target.lnk

    target.lnk快捷方式指向网络位置

    desktop.ini具有精确的内容

    Option Explicit
    
    Function CreateNetworkLocation( networkLocationName, networkLocationTarget )
        Const ssfNETHOOD  = &H13&
        Const fsATTRIBUTES_READONLY = 1
        Const fsATTRIBUTES_HIDDEN = 2
        Const fsATTRIBUTES_SYSTEM = 4
    
        CreateNetworkLocation = False 
    
        ' Instantiate needed components
        Dim fso, shell, shellApplication
            Set fso =               WScript.CreateObject("Scripting.FileSystemObject")
            Set shell =             WScript.CreateObject("WScript.Shell")
            Set shellApplication =  WScript.CreateObject("Shell.Application")
    
        ' Locate where NetworkLocations are stored
        Dim nethoodFolderPath, networkLocationFolder, networkLocationFolderPath
            nethoodFolderPath = shellApplication.Namespace( ssfNETHOOD ).Self.Path
    
        ' Create the folder for our NetworkLocation and set its attributes
            networkLocationFolderPath = fso.BuildPath( nethoodFolderPath, networkLocationName )
            If fso.FolderExists( networkLocationFolderPath ) Then 
                Exit Function 
            End If 
            Set networkLocationFolder = fso.CreateFolder( networkLocationFolderPath )
            networkLocationFolder.Attributes = fsATTRIBUTES_READONLY
    
        ' Write the desktop.ini inside our NetworkLocation folder and change its attributes    
        Dim desktopINIFilePath
            desktopINIFilePath = fso.BuildPath( networkLocationFolderPath, "desktop.ini" )
            With fso.CreateTextFile(desktopINIFilePath)
                .Write  "[.ShellClassInfo]" & vbCrlf & _ 
                        "CLSID2={0AFACED1-E828-11D1-9187-B532F1E9575D}" & vbCrlf & _ 
                        "Flags=2" & vbCrlf
                .Close
            End With 
            With fso.GetFile( desktopINIFilePath )
                .Attributes = fsATTRIBUTES_HIDDEN + fsATTRIBUTES_SYSTEM
            End With 
    
        ' Create the shortcut to the target of our NetworkLocation
        Dim targetLink
            targetLink = fso.BuildPath( networkLocationFolderPath, "target.lnk" )
            With shell.CreateShortcut( targetLink )
                .TargetPath = networkLocationTarget
                .Save
            End With        
    
        ' Done
            CreateNetworkLocation = True 
    
    End Function
    
    CreateNetworkLocation "共享名称", "\\IPv4地址\c$"
    

    具体内容可参考帖子Add new network location not map network device

    此答案是否有帮助?

    1 个人认为此答案很有帮助。
    0 个注释 无注释