For the love of god, will someone please explain to me why I can't simply use the fso.GetAbsolutePathName function within Vbscript to get the directory path of where the script is running from. I've searched all over on how to do this, but I can't seem to find anything that would be helpful in my case.

Here is how my script looks at the moment.

Dim fso, WshShell

const EVENTLOG_INFORMATION = 4
const HKEY_LOCAL_MACHINE = &H80000002

Set WshShell = WScript.CreateObject("WScript.Shell")
Set fso = WScript.CreateObject("Scripting.Filesystemobject")

DIR = fso.GetAbsolutePathName (".")

wshshell.Exec "msiexec.exe /i product1.msi TRANSFORMS=product1.mst PATCH=DIR\product1.MSP"  

When I executabe the script, I end up with error 1635. If I execute the script with the below code, then it runs just fine.

wshshell.Exec "msiexec.exe /i product1.msi TRANSFORMS=product1.mst PATCH=C:\test\product1.MSP

Does anyone know why I can't use the DIR variable I am setting within my path for the PATCH file?

Thanks for any input you guys can provide

 

0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Answers

0

The below code shoud do the trick

 

Dim FSO, WshShell

Set WshShell = CreateObject("WScript.Shell")
Set FSO = WScript.CreateObject("Scripting.Filesystemobject")

DIR = FSO.GetAbsolutePathName (".")

wshshell.Run "msiexec /i " & Chr(34) & DIR & "\product1.msi" & Chr(34) & " TRANSFORMS=" & Chr(34) & DIR & "\product1.mst" & Chr(34) & " PATCH=" & Chr(34) & DIR & "\product1.MSP" & Chr(34)

Set WshShell = Nothing
Set FSO = Nothing

Answered 03/02/2013 by: jagadeish
Red Belt

Please log in to comment
0

Why futz with nasty old command line MSIExec when the entire WI object model is accessible by script? :-)

Answered 03/05/2013 by: VBScab
Red Belt

Please log in to comment
0

It looks like the only reason your script did not work previously is because you passed the DIR variable as text instead of as a variable, therefore the path did not exist and you received the error.  Try the code below instead.  All I changed was the last line.

Dim fso, WshShell

Const EVENTLOG_INFORMATION = 4

Const HKEY_LOCAL_MACHINE = &H80000002

Set WshShell = WScript.CreateObject("WScript.Shell")

Set fso = WScript.CreateObject("Scripting.Filesystemobject")

DIR = fso.GetAbsolutePathName (".")

wshshell.Exec "msiexec.exe /i product1.msi TRANSFORMS=product1.mst PATCH=" & DIR & "\product1.MSP"

Answered 03/05/2013 by: M P
Purple Belt

Please log in to comment
Answer this question or Comment on this question for clarity