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上执行,并不能将字体文件安装到系统,如何改代码才可以通过?
试试: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()