last week, one of my colleagues asked me if embedded MST files in an MSI installer can be extracted for verification. i had tried out several MSI APIs mostly using VBScript in retrieving info on MSI and MSPs 2-3 years back when i was studying the installer concept. well, with the MSI APIs, you can access the _Storages table of the installer and lists the names of the embedded MSTs. however, the Data field which holds the binary data cannot be accessed and will also return a data size of 0bytes! API description in MSDN clearly states this too...
anyway, so what i did was to make use of msidb.exe utility which is shipped with the MS platform SDK. you will need to specify the MSI file path and the name of the storage i.e. the MST (usually the codepage or locale number) to extract the file. i used the MSI APIs in vbscript to list the names of the embedded storages and specify them in the commandline option of msidb.exe to extract it...
last weekend, i had some free time to check on the MSI APIs. i was wondering how msidb.exe is extracting the data since the description in the _Storages table notes that the Data field cannot be accessed!? after awhile, i came to understand that you'll have to treat the msi file as any compound file like Office files which have embedded storages in them. and this led me to the IStorage::OpenStorage and related APIs in MSDN. using these OLE Storage related APIs, i was able to extract the MSTs and save them externally.
here's the command line tool (stgxtr.exe) which will extract all the data in the storage of a compound file. i just tested this with an MSI so i don't have any idea if this works with other compound files...
[Usage]
$>stgxtr.exe <pathToMSIFileWithEmbeddedMST>
the extracted files will be saved on the current directory and are named with their corresponding storage names. i currently did not add the feature of extracting specific storage name but might implement it later when necessary. if you need to extract specific storage out of the MSI, you can use msidb.exe instead.
Tuesday, February 16, 2010
Thursday, January 21, 2010
Technology to watch out in 2010
One technology which will be make Citrix known to general consumers will be its XenClient software. It's currently on it beta stage and is still in development. Watch the demo video during the Synergy.
Tuesday, October 27, 2009
Thursday, September 24, 2009
VBS Utility Class
i had written several vbs and hta scripts at work to do some automation for me. here's a utility class for registry read/write, file create/write, getting hostname and others. just customize it in anyway you want. if you have any questions, just drop me a line.
[listing 1] Util class
--------------------------
--------------------------
[listing 1] Util class
--------------------------
Class Util
Dim m_oFso, m_oShl, m_oNet, m_appLoc
Private Sub Class_Initialize
Set m_oFso = CreateObject("Scripting.FileSystemObject")
Set m_oShl = CreateObject("WScript.Shell")
Set m_oNet = CreateObject("WScript.Network")
m_appLoc = m_oFso.GetFolder(".")
End Sub
Private Sub Class_Terminate
Set m_oFso = Nothing
Set m_oShl = Nothing
Set m_oNet = Nothing
End Sub
Public Property Get HostName
HostName = m_oNet.ComputerName
End Property
Public Sub CopyFolder(srcDir, tarDir, bOverWrite)
m_oFso.CopyFolder srcDir, tarDir, bOverWrite
End Sub
Public Sub DeleteFolderFiles(folderPath)
Dim oFile, oFolder
If Not m_oFso.FolderExists(folderPath) Then Exit Sub
Set oFolder = m_oFso.GetFolder(folderPath)
For Each oFile In oFolder.Files
DeleteFile oFile
Next
End Sub
Public Sub DeleteFile(strPath)
m_oFso.DeleteFile strPath, True
End Sub
Public Sub CreateFile(strPath)
Dim g: Set g = m_oFso.CreateTextFile(strPath)
g.Close
End Sub
Public Sub RenameFile(strOrig, strNew)
m_oFso.MoveFile strOrig, strNew
End Sub
Public Sub CreateFolder(strPath)
If m_oFso.FolderExists(strPath) Then Exit Sub
Dim oPF: oPF = m_oFso.GetParentFolderName(strPath)
If Not m_oFso.FolderExists(oPF) Then CreateFolder oPF
m_oFso.CreateFolder(strPath)
End Sub
Public Function PathExists(strPath)
Dim bRes: bRes = m_oFso.FileExists(strPath)
If Not bRes Then bRes = m_oFso.FolderExists(strPath)
PathExists = bRes
End Function
Public Function WriteReg(keyRoot, vValue, vType)
On Error Resume Next
m_oShl.RegWrite keyRoot, vValue, vType
WriteReg = (Err.Number = 0)
End Function
Public Function WriteRegString(keyRoot, strValue)
WriteRegString = WriteReg(keyRoot, strValue, "REG_SZ")
End Function
Public Function WriteRegExpString(keyRoot, strValue)
WriteRegExpString = WriteReg(keyRoot, strValue, "REG_EXPAND_SZ")
End Function
Public Function WriteRegDword(keyRoot, dwValue)
WriteRegDword = WriteReg(keyRoot, dwValue, "REG_DWORD")
End Function
Public Function WriteRegBinary(keyRoot, binValue)
WriteRegBinary = WriteReg(keyRoot, binValue, "REG_BINARY")
End Function
Public Function ReadReg(keyRoot)
On Error Resume Next
ReadReg = m_oShl.RegRead(keyRoot)
If Not Err.Number = 0 Then ReadReg = "[notfound]"
End Function
Public Function RegValueExist(keyRoot)
RegValueExist =( ReadReg(keyRoot) <> "[notfound]")
End Function
Public Property Get AppPath
AppPath = m_appLoc
End Property
Public Function RunCommand(cmd)
RunCommand = ""
On Error Resume Next
Dim tmpOut: tmpOut = m_oShl.ExpandEnvironmentStrings("%TEMP%\$tmp.out")
Dim retCode: retCode = m_oShl.Run("%comspec% /c " & cmd & " >""" & tmpOut & """" , 0, True)
Dim outFile: Set outFile = m_objFso.OpenTextFile(tmpOut)
If Err.Number <> 0 Then
RunCommand = outFile.ReadAll
'MsgBox outFile.ReadAll
outFile.Close
m_objFso.DeleteFile tmpOut
End If
Set outFile = Nothing
End Function
Public Sub RunRawCmd(cmd, bWin,bWait)
m_oShl.Run "%comspec% /c " & cmd, bWin, bWait
End Sub
Public Sub RestartSystem()
m_oShl.Run "shutdown -r -f -t 00", 0, False
End Sub
Public Function ImportRegFile(regFile)
'ImportRegFile = RunCommand("reg import """ & regFile & """")
ImportRegFile = RunCommand("regedit /s """ & regFile & """")
End Function
Public Sub Sleep(nSecs)
Dim t: t="~$slp.vbs"
RunRawCmd "echo wscript.sleep " & nSecs & "000> " & t & " & " & t & " & del /f/q " & t, 0, True
End Sub
Public Property Let CurrentDirectory(strDir)
m_oShl.CurrentDirectory = strDir
End Property
Public Property Get CurrentDirectory
CurrentDirectory = m_oShl.CurrentDirectory
End Property
End Class--------------------------
Tuesday, September 15, 2009
File Comparison Batch Script
at work, i needed to compare the files in the mounted ISO image to the extracted raw files. there are several tools which compares directories like the built-in fc.exe of windows and other freewares but what i needed is something simple which would only check for the files on the the same folder location which is just relative to the root location. for example, the mounted ISO image is my reference subject and the files in it should be found on the extracted file structure of the same relative folder location.
here's what i've came up. posting it here for future reference and for those who might have the same needs.
listing: compdir.bat
---------------
::reference dir
@set REFDIR=%~1
::this is the copied directory which should be checked
@set CMPDIR=%~2
::call the root first
@call :CMPPROC
@goto XXX
:CMPPROC
@set MRGPATH=%REFDIR%%~1
@echo RefDir: %MRGPATH%
@echo TarDir: %CMPDIR%%~1
@echo ------------------------------------
::check on the files
@for /f "usebackq tokens=* delims=" %%i in (`@dir /b/a:-d "%MRGPATH%"`) do @if exist "%CMPDIR%%~1\%%i" (@call :CMPFILE "%%i" "%MRGPATH%\%%i" "%CMPDIR%%~1\%%i" ) else (@echo [NG] "%%i")
@echo ------------------------------------
::iterate on the sub directories
@for /f "usebackq tokens=* delims=" %%i in (`@dir /b/a:d "%MRGPATH%"`) do @call :CMPPROC "%~1\%%i"
@goto :EOF
:CMPFILE
@fc /B "%~2" "%~3" >nul
@if %ERRORLEVEL%==0 (@echo [OK] "%~1") else (@echo [NG] "%~1")
@goto :EOF
:XXX
@echo Done
---------------
here's what i've came up. posting it here for future reference and for those who might have the same needs.
listing: compdir.bat
---------------
::reference dir
@set REFDIR=%~1
::this is the copied directory which should be checked
@set CMPDIR=%~2
::call the root first
@call :CMPPROC
@goto XXX
:CMPPROC
@set MRGPATH=%REFDIR%%~1
@echo RefDir: %MRGPATH%
@echo TarDir: %CMPDIR%%~1
@echo ------------------------------------
::check on the files
@for /f "usebackq tokens=* delims=" %%i in (`@dir /b/a:-d "%MRGPATH%"`) do @if exist "%CMPDIR%%~1\%%i" (@call :CMPFILE "%%i" "%MRGPATH%\%%i" "%CMPDIR%%~1\%%i" ) else (@echo [NG] "%%i")
@echo ------------------------------------
::iterate on the sub directories
@for /f "usebackq tokens=* delims=" %%i in (`@dir /b/a:d "%MRGPATH%"`) do @call :CMPPROC "%~1\%%i"
@goto :EOF
:CMPFILE
@fc /B "%~2" "%~3" >nul
@if %ERRORLEVEL%==0 (@echo [OK] "%~1") else (@echo [NG] "%~1")
@goto :EOF
:XXX
@echo Done
---------------
Monday, August 17, 2009
M$ Word patent infringement
Last week, many articles went out after the Texas federal court judgment in favor of i4i, a Canadian software companion. The dispute was related to M$ usage of custom XML methodology in its Office suite especially Word, for which i4i owns the technology patent. One blog article disclosed that M$ developers knew about this technology before Word 2003/2007 was developed and that one developer's email stating "i4i will become obsolete" when the new version of Word goes out to market. Following the court's decision, M$ was ordered to stop selling its Word application and this becomes a worry to the many enterprises who had been using Word especially those companies primarily using SharePoint. the current case is still not over though. M$ had filed an appeal and might be settling this off the court... perhaps might even buy i4i! M$ has been ordered to pay around $300M and to stop selling those Word apps. You may expect M$ to either release a hotfix or patch to remove reading custom XML files in Word; or rather M$ to get into a licensing agreement with i4i for its technology.
related articles:
Jury orders Microsoft to pay $200M in damages to i4i
Judge bans Microsoft from selling Word
google: i4i+word
related articles:
Jury orders Microsoft to pay $200M in damages to i4i
Judge bans Microsoft from selling Word
google: i4i+word
Thursday, July 30, 2009
Windows 7 RTMed
last week, Windows 7 has been RTMed (details here). having just tried playing with the RC builds on my work, there are several new features which seems very alluring to have like native support for ISO image burning. this article lists several good things in Windows7. but will it really sell out? i'm still pessimistic about it but once it starts shipping out the Windows7 lite version for the netbooks, i think it will then start selling. but again, considering the compatibility of old devices/drivers and softwares, many people will stick to the old windows XP for a little while. anyway, let's just wait for it release and go-to-market date. my personal advice however, is to wait....
Subscribe to:
Posts (Atom)