以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  将字体文件安装到系统,代码如何写?  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=192295)

--  作者:kgdce
--  发布时间:2024/6/11 19:35:00
--  将字体文件安装到系统,代码如何写?
If filesys.FileExists("C:\\Windows\\ Fonts\\HYT_OMR_Jx.ttf") Then
    Output.Show("1")
Else
    Dim fstr As String = projectpath & "Attachments\\HYT_OMR_Jx.ttf"
    Dim f As String = SpecialFolder.SYSTEM
    f = f.Substring(0, f.LastIndexOf("\\")) & "\\Fonts\\HYT_OMR_Jx.ttf" 
    Dim fcmd As String = projectpath & "Attachments\\test.bat" 
    FileSys.WriteAllText(fcmd, "copy " & fstr & " " & f & " /y", False, encoding.default)
    \'FileSys.WriteAllText(fcmd, "copy " & fstr & " " & f & " /y" & vbcrlf & "pause", False, encoding.default)
    System.Diagnostics.Process.Start("Explorer", "  /select," & fcmd & " ")
    system.threading.thread.sleep(1000)
    Sendkeys.Send("{enter}")
End If
上述代码,bat文件在win10上执行,并不能将字体文件安装到系统,如何改代码才可以通过?

--  作者:有点蓝
--  发布时间:2024/6/11 21:24:00
--  
试试:https://www.baidu.com/s?wd=c%23%20%E5%AE%89%E8%A3%85%E5%AD%97%E4%BD%93

Dim fontPath As String = projectpath & "Attachments\\HYT_OMR_Jx.ttf"
dim fontSysFolder as string = "C:\\Windows\\Fonts\\"
Dim args as string = "-install """ & fontPath & """"

Dim p As New Process() p.StartInfo.FileName = "cmd.exe" p.StartInfo.Arguments = "/C fontview " & args p.StartInfo.UseShellExecute = True p.Start()