Unicode命名为Folder显示吗?在wscript提示中 [英] Unicode named Folder shows ? in wscript prompt

查看:51
本文介绍了Unicode命名为Folder显示吗?在wscript提示中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用Unicode命名文件夹时遇到问题.当我将文件夹拖到脚本时,它无法正确显示文件夹的路径.

I am facing problems with Unicode named folders. When I drag the folder to the script, it doesn't show the path of the folder properly.

简单的VBScript(这只是其中的一部分):

Simple VBScript (this is just a portion of it):

Dim Wshso : Set Wshso = WScript.CreateObject("WScript.Shell")
Dim FSO : Set FSO = CreateObject("Scripting.FileSystemObject")

If WScript.Arguments.Count = 1 Then
    If FSO.FileExists(Wscript.Arguments.Item(0)) = true and FSO.FolderExists(Wscript.Arguments.Item(0)) = false Then
        Alert "You dragged a file, not a folder! My god." & vbcrlf & "Script will terminate immediately", 0, "Alert: User is stupid", 48
        WScript.Quit
    Else
        targetDir = WScript.Arguments.Item(0)
        Wshso.Popup targetDir
    End If
Else
    targetDir = Wshso.SpecialFolders("Desktop")
    Alert "Note: No folder to traverse detected, default set to:" & vbcrlf & Wshso.SpecialFolders("Desktop"), 0, "Alert", 48
End If

如果它是不带Unicode字符的普通路径,则可以.但是在这种情况下:目录: 4分钟(포미닛)-击中你的心

If it is a normal path without Unicode characters, it's fine. But in this case: Directory: 4minute (포미닛) - Hit Your Heart

然后它将显示类似 4minute(?)-Hit Your Heart

如果我执行FolderExists,则找不到拖动的文件夹.

And if I do a FolderExists it can't find the dragged folder.

是否有任何变通方法来支持名为Unicode的Folders?

Is there any workaround to support Unicode named Folders?

谢谢!

如果不够清楚,我会进行编辑

I'll edit if this is not clear enough

推荐答案

这似乎是Windows脚本宿主的

This does seem to be a problem peculiar to the Windows Script Host's DropHandler shell extension. Whereas:

test.vbs "C:\포미닛.txt"
C:\WINDOWS\System32\WScript.exe "test.vbs" "C:\포미닛.txt"

在控制台上键入

都可以工作(即使控制台无法渲染韩文,因此它看起来像?),拖放操作(应导致相同的命令)也会通过Unicode-> ANSI-> Unicode转换将丢失当前ANSI代码页中没有的所有字符.(因此포미닛将在默认的朝鲜语Windows安装环境下工作,但不适用于西方语言.)

both work when typed from the console (even if the console can't render the Hangul so it looks like ?), a drag and drop operation that should result in the same command goes through a Unicode->ANSI->Unicode translation that loses all characters that aren't in the current ANSI code page. (So 포미닛 will work on a default Korean Windows install but not Western.)

我不知道解决此问题的正确方法.您也许可以通过更改注册表中的.vbs文件的DropHandler来解决此问题:

I'm not aware of a proper way to fix the problem. You could perhaps work around it by changing the DropHandler for .vbs files in the registry:

HKEY_CLASSES_ROOT\VBSFile\ShellEx\DropHandler\(Default)

从WSH DropHandler( {60254CA5-953B-11CF-8C96-00AA00B8708C} )到 {86C86720-42A0-1069-A2E8-08002B30309D} ,适用于.exe,.bat和类似文件,而不会遇到此问题.您可能还必须更改.vbs的文件关联,以便也将引号引起来,因为EXE DropHandler不会,以免文件名中出现空格.

from the WSH DropHandler ({60254CA5-953B-11CF-8C96-00AA00B8708C}) to {86C86720-42A0-1069-A2E8-08002B30309D}, the one used for .exe, .bat and similar, which doesn't suffer from this issue. You would also probably have to change the file association for .vbs to put quotes around the filename argument too, since the EXE DropHandler doesn't, to avoid problems with spaces in filenames.

由于这会影响所有VBS文件的参数传递,因此在您自己的计算机上部署这将是一个危险的修补程序.如果需要这样做,也许可以尝试使用适当的DropTarget创建新的文件扩展名,而不是更改VBSFile本身?或者也许放弃按脚本操作,而是提供文件打开"对话框或手动放置字段.

Since this affects argument-passing for all VBS files it would be a perilous fix to deploy on any machine but your own. If you needed to do that, maybe you could try creating a new file extension with the appropriate DropTarget rather than changing VBSFile itself? Or maybe forgo drop-onto-script behaviour and provide a file Open dialog or manual drop field instead.

这篇关于Unicode命名为Folder显示吗?在wscript提示中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆