什么原因导致 assoc 说“系统找不到指定的文件”?

什么原因导致 assoc 说“系统找不到指定的文件”?

我正在从管理命令提示符运行 assoc

我想在关联列表中添加 .vbsc 条目。它不允许我这样做,但它允许我为 .vbsd 添加一个条目,并且它正在运行 assoc。(如果它没有找到 assoc,它会说它无法识别)。那么发生了什么?

我确实有一个程序(cscript.exe 的包装器),我已将其链接到 .vbsc 文件,它确实附加了,但正如您从 grep 中看到的那样,由于某种原因,它没有在 assoc 中列出,这很奇怪,但我在这里询问的奇怪之处(可能相关),是为什么assoc .vbsc=我的机器上显示“系统找不到指定的文件”?

C:\>assoc .vbsc=  <--- fails, i'd expect it to work
The system cannot find the file specified.

C:\>assoc .abc=  <-- works, no error

C:\>assoc .abcd= <-- works, no error

C:\>assoc .vbsd=  <-- works, no error

C:\>

并提醒当命令无法识别时会显示什么。

C:\>hjghjgjhgjh
'hjghjgjhgjh' is not recognized as an internal or external command,
operable program or batch file.

C:\>

和更多信息

C:\>assoc | grep -i vbs
.vbs=VBSFile

C:\>ftype | grep -i vbs
VBSFile=C:\blah\mycscriptwrapper.exe %1
VBS_Cscr=C:\blah\mycscriptwrapper.exe %1

C:\>

补充说明

如果有人发现上面的箭头和描述很难理解,并且不喜欢英语而只想看截图,这里有一个截图的链接,它只显示了上面内容的主要部分。

在此处输入图片描述

而且事情变得越来越奇怪。

在此处输入图片描述

Jozef 提出了一些建议,我认为这可能是一个重大突破。使用reg query hkcr\.vbsc/s 执行 and。将其与 .abc 进行比较,就会发现差异。

更新 我会将其合并到 jozef 的答案中..但这里暂时作为记录。

    C:\Users\harvey>reg query hkcr\.vbsc

    HKEY_CLASSES_ROOT\.vbsc\OpenWithList
    HKEY_CLASSES_ROOT\.vbsc\PersistentHandler
    HKEY_CLASSES_ROOT\.vbsc\Shell

    C:\Users\harvey>reg query hkcr\.vbsc  /s

    HKEY_CLASSES_ROOT\.vbsc\OpenWithList

    HKEY_CLASSES_ROOT\.vbsc\PersistentHandler
        OriginalPersistentHandler    REG_SZ    {00000000-0000-0000-0000-000000000000
    }

    HKEY_CLASSES_ROOT\.vbsc\Shell

    HKEY_CLASSES_ROOT\.vbsc\Shell\Open

    HKEY_CLASSES_ROOT\.vbsc\Shell\Open\Command
        (Default)    REG_EXPAND_SZ    VBS_Cscr


    C:\Users\harvey>

使用 .abc,甚至使用

关联 abc=RAZ

(即使设置了 ftype,它仍然只适用于 .abc )

C:\Users\harvey>reg query hkcr\.abc

HKEY_CLASSES_ROOT\.abc
    (Default)    REG_SZ    RAZ


C:\Users\harvey>

with ftype set you also get this key 

ftype RAZ=c:\blah\blah.exe

C:\Users\harvey>reg query hkcr\RAZ /s

HKEY_CLASSES_ROOT\RAZ\Shell

HKEY_CLASSES_ROOT\RAZ\Shell\Open

HKEY_CLASSES_ROOT\RAZ\Shell\Open\Command
    (Default)    REG_EXPAND_SZ    c:\blah\blah.exe


C:\Users\harvey>

C:\Users\harvey>reg delete hkcr\.vbsc
Permanently delete the registry key HKEY_CLASSES_ROOT\.vbsc (Yes/No)? y
The operation completed successfully.

现在它可以工作了..不知道其他条目是怎么到那里的..可能是“默认程序编辑器”和开始的混合..“更改与特定扩展名相关联的文件类型”并制作.vbsc 图标并选择带有打开方式和关联的程序。

在此处输入图片描述

答案1

补充了 barlop 的注释—— 解决方案是故障排除步骤,reg query hkcr\.vbsd使用 /s 将包括值等。这与 hkcr.abcd 不同,解决方案是删除该密钥。让 assoc 生成密钥以及该密钥中所需的内容。----

经过所有解释后,我可以重现该问题:

C:\Windows\system32> assoc .vbsd=

C:\Windows\system32> assoc .vbsd=abc
.vbsd=abc

C:\Windows\system32> assoc .vbsd=

C:\Windows\system32> assoc .vbsd=

C:\Windows\system32> reg add HKCR\.vbsd\AnyKeyName /f
The operation completed successfully.

C:\Windows\system32> assoc .vbsd=
The system cannot find the file specified.

C:\Windows\system32> reg delete HKCR\.vbsd\AnyKeyName /f
The operation completed successfully.

C:\Windows\system32> assoc .vbsd=

C:\Windows\system32> assoc .vbsd=

C:\Windows\system32>

以下是来自进程监控: 成功的assoc .vbsd=

"Process Name","Operation","Path","Result","Detail"
"cmd.exe","RegQueryKey","HKLM","SUCCESS","Query: HandleTags, HandleTags: 0x0"
"cmd.exe","RegOpenKey","HKCR","SUCCESS","Desired Access: Maximum Allowed, Granted Access: All Access"
"cmd.exe","RegQueryKey","HKCR","SUCCESS","Query: HandleTags, HandleTags: 0x0"
"cmd.exe","RegOpenKey","HKCR\.vbsd","SUCCESS","Desired Access: Delete"
"cmd.exe","RegDeleteKey","HKCR\.vbsd","SUCCESS",""
"cmd.exe","RegCloseKey","HKCR\.vbsd","SUCCESS",""
"cmd.exe","RegQueryKey","HKLM","SUCCESS","Query: HandleTags, HandleTags: 0x0"
"cmd.exe","RegOpenKey","HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer","SUCCESS","Desired Access: Query Value"
"cmd.exe","RegQueryValue","HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\GlobalAssocChangedCounter","SUCCESS","Type: REG_DWORD, Length: 4, Data: 108"
"cmd.exe","RegCloseKey","HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer","SUCCESS",""
"cmd.exe","RegQueryKey","HKLM","SUCCESS","Query: HandleTags, HandleTags: 0x0"
"cmd.exe","RegCreateKey","HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer","SUCCESS","Desired Access: Set Value, Disposition: REG_OPENED_EXISTING_KEY"
"cmd.exe","RegSetValue","HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\GlobalAssocChangedCounter","SUCCESS","Type: REG_DWORD, Length: 4, Data: 109"
"cmd.exe","RegCloseKey","HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer","SUCCESS",""
"cmd.exe","RegCloseKey","HKCR","SUCCESS",""

并且失败assoc .vbsd=并出现意外The system cannot find the file specified消息:

"Process Name","Operation","Path","Result","Detail"
"cmd.exe","RegQueryKey","HKLM","SUCCESS","Query: HandleTags, HandleTags: 0x0"
"cmd.exe","RegOpenKey","HKCR","SUCCESS","Desired Access: Maximum Allowed, Granted Access: All Access"
"cmd.exe","RegQueryKey","HKCR","SUCCESS","Query: HandleTags, HandleTags: 0x0"
"cmd.exe","RegOpenKey","HKCR\.vbsd","SUCCESS","Desired Access: Delete"
"cmd.exe","RegDeleteKey","HKCR\.vbsd","CANNOT DELETE",""
"cmd.exe","RegCloseKey","HKCR\.vbsd","SUCCESS",""
"cmd.exe","RegQueryKey","HKCR","SUCCESS","Query: HandleTags, HandleTags: 0x0"
"cmd.exe","RegOpenKey","HKCR\.vbsd","SUCCESS","Desired Access: Maximum Allowed, Granted Access: All Access"
"cmd.exe","RegDeleteValue","HKCR\.vbsd\(Default)","NAME NOT FOUND",""
"cmd.exe","RegCloseKey","HKCR\.vbsd","SUCCESS",""
"cmd.exe","RegCloseKey","HKCR","SUCCESS",""

不幸的是,在您的情况下,我无法发现下面的子键HKCR\.vbsc来自哪里。

添加了 barlop 的注释 --- 至于它来自哪里,我认为它是“默认程序编辑器”和 start/orb 的组合......“更改与特定扩展名关联的文件类型”并制作 .vbsc 图标并选择带有打开方式的程序,然后关联 ----

相关内容