Reason for this post is that if you attempt to use the PATCH property it requires that you provide the full path to the patch, there are other methods for obtaining this which is at the bottom of this post. If you are wondering about the strLog I got a little bored, I am sure there is a more efficient way of creating the log file name.
On Error Resume Next
Dim wshShell, strMSI, strTransform, strPatch, objFSO, strLogPath
Set wshShell = WScript.CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
strMSI = "YourMSI.msi"
strTransform = "YourMST.mst"
strPatch = objFSO.GetAbsolutePathName("") & "\" & "YourPatch.msp"
strLog = wshShell.ExpandEnvironmentStrings("%windir%") & "\MSILogs\" & Left(strMSI, InStr(strMSI,".msi")) & "log"
wshShell.Run "msiexec /i " & """" & strMSI & """" & " TRANSFORMS=" & """" & strTransform & """" & " PATCH=" & """" & strPatch & """" & " /qb! /norestart /l*v " & strLog, 0, True
Set wshShell = Nothing
Set objFSO = Nothing
If err.Number = 0 Then
wScript.Quit 0
Else
wScript.Quit err.Number
End If
Obtained from:
http://www.visualbasicscript.com/how-to-get-working-drive-and-directory-m1248.aspx
Set fso = CreateObject("Scripting.FileSystemObject")
GetAbsolutePath = fso.GetAbsolutePathName("Wscript.ScriptName") 'Returns path and file name of file specified
GetTheParent = fso.GetParentFolderName("Wscript.ScriptName")'Returns the parentfolder of the Path/File specified
GetTheBase = fso.GetBaseName("Wscript.ScriptName")'Returns the file name minus file extension
GetTheScriptFullName = WScript.ScriptFullName'Returns path of the script being called.
GetTheScriptName = Wscript.ScriptName'Returns the name of the script
msgbox "Using AbsolutePath: " & GetAbsolutePath & vbcr _
& "Using GetParentFolderName: " & GetTheParent & vbcr _
& "Using GetBaseName: " & GetTheBase & vbcr _
& "Using ScriptFullName: " & GetTheScriptFullName & vbcr _
& "Using ScriptName: " & GetTheScriptName
Or if you use batch files:
Echo %~f0
http://stackoverflow.com/questions/1421286/getting-a-batch-files-full-path
No comments:
Post a Comment