/build/static/layout/Breadcrumb_cap_w.png

How to properly use fso.GetAbsolutePathName in VBScript

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

Answers (3)

Posted by: jagadeish 11 years ago
Red Belt
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

Posted by: anonymous_9363 11 years ago
Red Belt
0

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

Posted by: M P 11 years ago
Purple Belt
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"

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ