溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

域環(huán)境users提權(quán)調(diào)用lsrunase.exe 批處理完成安裝字體

發(fā)布時(shí)間:2020-07-09 08:38:03 來源:網(wǎng)絡(luò) 閱讀:1132 作者:lv287 欄目:系統(tǒng)運(yùn)維

字體安裝2.0
由于字體安裝之前的批處理采用字體文件復(fù)制到c:\windows\fonts下再注冊(cè)注冊(cè)表的方式,一部分字體安裝不上,重新修改了批處理方式。

一. 字體安裝批處理
1.vbs腳本運(yùn)行安裝D:\fonts下的字體安裝包,安裝時(shí)fonts.vbs同時(shí)會(huì)檢測(cè)C:\windows\fonts\字體名稱與D:\fonts里的字體名是否一致,如果存在則忽略掉。缺點(diǎn):若是表面字體名不一致,會(huì)提示重復(fù)安裝,手動(dòng)單擊選擇即可。
參考的事例:
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%,特殊類型的字體安裝再擴(kuò)展。

  1. 使用vbs封裝成exe文件工具,封裝vbs腳本,命名可執(zhí)行文件的fonts.exe。
    (bat不能直接運(yùn)行VBS,水平有限直接做成了exe來執(zhí)行)
    下載地址:https://download.csdn.net/download/qq_16066381/9760279

域環(huán)境users提權(quán)調(diào)用lsrunase.exe 批處理完成安裝字體

二.使用Quick_Batch_File_Compiler封裝以管理員運(yùn)行的批處理.批處理用到lsrunas.exe加密域管理員密碼來運(yùn)行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調(diào)用域管理員權(quán)限來運(yùn)行本地自解壓文件完成軟件安裝rem 利用lsrunase調(diào)用域管理員權(quán)限來運(yùn)行本地自解壓文件完成軟件安裝

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

2.Quick_Batch_File_Compiler封裝命名為 雙擊本軟件_安裝字體.exe

三.介于軟件bug,做了其他輔助性的批處理來完善使用
字體提示已安裝太多情況1.強(qiáng)制結(jié)束安裝進(jìn)程,2.清理fonts下已安裝的字體

11強(qiáng)制結(jié)束_安裝字體.bat
@echo off
taskkill /f /im fonts.exe
結(jié)束字體安裝進(jìn)程

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 刪除之前的快捷方式,創(chuàng)建新的快捷方式,并運(yùn)行完刪除自己
@echo off
copy /y "D:\fonts\安裝字體.lnk" c:\users\public\desktop
rem 在公共桌面創(chuàng)建快捷方式
ping 127.1 -n 2 >nul
del D:\fonts\安裝字體.lnk
del /f /q /a /s %0
rem 刪除批處理本身

四.封裝自解壓
自解壓的封裝方法百度一下。
域環(huán)境users提權(quán)調(diào)用lsrunase.exe 批處理完成安裝字體

1.解壓后的Fonts.exe 屬性隱藏,防止誤刪
2.注意命名的安裝軟件排在所有文件前面。字體文件很多情況下,會(huì)造成找不到
域環(huán)境users提權(quán)調(diào)用lsrunase.exe 批處理完成安裝字體

五.宣導(dǎo),或者編輯安裝方法文檔。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI