Wednesday, 17 June 2009

Font Installation using VBscript

The script:
'=========================
'Syntax: "InstallFont.vbs" /Font:""
'=========================
Option Explicit
Dim FSO
Set FSO = CreateObject("Scripting.FileSystemObject")
If FSO.FileExists(WScript.Arguments.Named.Item("Font")) Then
Dim WSH
Set WSH = CreateObject("WScript.Shell")
'Coping the font file into the system folter Fonts
FSO.CopyFile WScript.Arguments.Named.Item("Font"), WSH.SpecialFolders("Fonts") & "\"
'Installaton of the font using API
WSH.Run "RunDll32.exe gdi32.dll,AddFontResourceA " & FSO.GetBaseName(WScript.Arguments.Named.Item("Font"))
End If

Additional *.bat file used for that task resolve:

REM========определение рабочих путей======
set mainpath=\\comp21\WORK\fontsinstall

REM========creating fontpaths.txt======
del %mainpath%\fontpaths.txt
FOR %%B in ("%mainpath%\fonts\"*.FON) do (echo %%B >> "%mainpath%\fontpaths.txt")
echo "fontpaths.txt is created"

REM========removing the fonts======
FOR /F "tokens=1-5 delims=\" %%B in (%mainpath%\fontpaths.txt) do (echo %%F removed & del %windir%\fonts\%%F)

REM========font installation======
FOR %%B in ("%mainpath%\fonts\"*.FON) do (%mainpath%\fontsinstall.vbs /Font:%%B & echo Font %%B is installed)

Thursday, 11 June 2009

Service Remote Start/Stop


Question: How to start/stop a service on a remote computer?

Answer: Using sc from command line.

examples:

  • sc \\Server1 start/stop "Service Number One"
  • runas /user:Domain1\admin "sc \\Server1 start \"Service Number One\""