温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

域环境users提权调用lsrunase.exe 批处理完成安装字体

发布时间:2020-07-09 08:38:03 来源:网络 阅读:1092 作者:lv287 栏目:系统运维

字体安装2.0
由于字体安装之前的批处理采用字体文件复制到c:\windows\fonts下再注册注册表的方式,一部分字体安装不上,重新修改了批处理方式。

一. 字体安装批处理
1.vbs脚本运行安装D:\fonts下的字体安装包,安装时fonts.vbs同时会检测C:\windows\fonts\字体名称与D:\fonts里的字体名是否一致,如果存在则忽略掉。缺点:若是表面字体名不一致,会提示重复安装,手动单击选择即可。
参考的事例:
http://blog.jasondahmen.com/2011/11/24/the-true-ultimate-font-install-for-windows-7-and-xp-vbs/
代码如下fonts.vbs
Option Explicit
' Installing multiple Fonts in Windows 7
' http://www.cloudtec.ch 2011
' Edited by Jason Dahmen

Dim objShell, objFSO, wshShell
Dim strFontSourcePath, objFolder, objFont, objNameSpace, objFile

Set objShell = CreateObject("Shell.Application")
Set wshShell = CreateObject("WScript.Shell")
Set objFSO = createobject("Scripting.Filesystemobject")

strFontSourcePath = "D:\fonts\"
If objFSO.FolderExists(strFontSourcePath) Then
If objFSO.FolderExists("C:\Users\") Then
' Start Windows 7/Vista
Set objNameSpace = objShell.Namespace(strFontSourcePath)
Set objFolder = objFSO.getFolder(strFontSourcePath)
For Each objFile In objFolder.files
If LCase(right(objFile,4)) = ".ttf" OR LCase(right(objFile,4)) = ".otf" OR LCase(right(objFile,4)) = ".ttc" Then
Set objFont = objNameSpace.ParseName(objFile.Name)
If objFSO.FileExists("C:\WINDOWS\Fonts\" & objFile.Name) = False Then
objFont.InvokeVerb("Install")
Set objFont = Nothing
Else
End If
End If
Next
Else
' Start Windows XP
Set objNameSpace = objShell.Namespace(strFontSourcePath)
Set objFolder = objFSO.getFolder(strFontSourcePath)
For Each objFile In objFolder.files
If LCase(right(objFile,4)) = ".ttf" OR LCase(right(objFile,4)) = ".otf" OR LCase(right(objFile,4)) = ".ttc" Then
Set objFont = objNameSpace.ParseName(objFile.Name)
If objFSO.FileExists("C:\WINDOWS\Fonts\" & objFile.Name) = False Then
objFSO.CopyFile "D:\fonts*", "c:\windows\fonts\"
Set objFont = Nothing
Else
End If
End If
Next
End If
Else
Wscript.Echo "Font Source Path does not exists"
End IF

注意:安装只包含ttf,otf,ttc三种字体文件,可以自己在代码加字体后缀( If LCase(right(objFile,4)) = ".ttf" OR LCase(right(objFile,4)) = ".otf" OR LCase(right(objFile,4)) = ".ttc" Then),满足95%,特殊类型的字体安装再扩展。

  1. 使用vbs封装成exe文件工具,封装vbs脚本,命名可执行文件的fonts.exe。
    (bat不能直接运行VBS,水平有限直接做成了exe来执行)
    下载地址:https://download.csdn.net/download/qq_16066381/9760279

域环境users提权调用lsrunase.exe 批处理完成安装字体

二.使用Quick_Batch_File_Compiler封装以管理员运行的批处理.批处理用到lsrunas.exe加密域管理员密码来运行fonts.exe

  1. 代码:Fonts-intsall.bat
    @echo off
    if "%1"=="h" goto begin
    start mshta vbscript:createobject("wscript.shell").run("""%~nx0"" h",0)(window.close)&&exit
    :begin
    \10.10.12.201\soft\install\lsrunase\lsrunase.exe /user:administrator /password:3lp9huRP3uydxg== /domain:zzecwwmir.com /command:d:\fonts\fonts.exe /runpath:d:\fonts\
    rem 利用lsrunase调用域管理员权限来运行本地自解压文件完成软件安装rem 利用lsrunase调用域管理员权限来运行本地自解压文件完成软件安装

参考lsrunase.exe
https://www.cnblogs.com/colinliu/p/5666715.html

2.Quick_Batch_File_Compiler封装命名为 双击本软件_安装字体.exe

三.介于软件bug,做了其他辅助性的批处理来完善使用
字体提示已安装太多情况1.强制结束安装进程,2.清理fonts下已安装的字体

11强制结束_安装字体.bat
@echo off
taskkill /f /im fonts.exe
结束字体安装进程

12删除以前的文件里的字体安装文件.bat
@echo off
del /f /q /a /s D:\fonts*.otf
del /f /q /a /s D:\fonts*.ttf
del /f /q /a /s D:\fonts*.fon
del /f /q /a /s D:\fonts*.ttc
rem 删除字体

Desk.bat 删除之前的快捷方式,创建新的快捷方式,并运行完删除自己
@echo off
copy /y "D:\fonts\安装字体.lnk" c:\users\public\desktop
rem 在公共桌面创建快捷方式
ping 127.1 -n 2 >nul
del D:\fonts\安装字体.lnk
del /f /q /a /s %0
rem 删除批处理本身

四.封装自解压
自解压的封装方法百度一下。
域环境users提权调用lsrunase.exe 批处理完成安装字体

1.解压后的Fonts.exe 属性隐藏,防止误删
2.注意命名的安装软件排在所有文件前面。字体文件很多情况下,会造成找不到
域环境users提权调用lsrunase.exe 批处理完成安装字体

五.宣导,或者编辑安装方法文档。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI