/build/static/layout/Breadcrumb_cap_w.png

Copy folder function using vbs

Hi..

I'm working on a MSI package which replaces some Excel addins with some localized versions of the addins. Facing a problem with the uninstall, since the locale files are replaced during installation, and the original files (non locale) are overwritten.

I was thinking of creating an VB script and running this script execute deferred before install, and one during uninstall.. However, i can't get the VB script to work properly. (that seems to be my problem most of the times.. Enough solutions, but geting them to work properly.. :P) This is what i've come up with so far:

dim filesys
dim progfolder
set filesys=CreateObject("Scripting.FileSystemObject")

If filesys.FolderExists("c:\program files\Microsoft Office\OFFICE11\Library\Analysis\") Then
Set progfolder = filesys.Getfolder("c:\program files\Microsoft Office\OFFICE11\Library\Analysis\")
progfolder.Copy("c:\program files\Microsoft Office\OFFICE11\Library\Analysis\EN\")
End If


So the general idea is to have the folder Analysis (or actually, only the contents) moved to Analysis\EN. However, the script tells me the directory c:\program files\Microsoft Office\OFFICE11\Library\Analysis\EN\ doesn't exist. If i change the target folder name to c:\test , the script runs fine. Probably something to do with the spaces in the path. (program files\microsoft office) Tried double quotes, & Chr(34), but still can't get it to work..

So i thought it might be an option to declare them as variables.. So i came up with this:

Dim strOldPath
Dim strNewPath
Dim Fso

strOldPath = "C:\Program Files\Microsoft Office\OFFICE11\Library\Analysis\ATPVBAEN.XLA"
strNewPath = "c:\Program Files\Microsoft Office\OFFICE11\Library\Analysis\EN\ATPVBAEN.XLA"

Set Fso = CreateObject("Scripting.FileSystemObject")

Set wshshell = WScript.CreateObject("WScript.Shell")
Fso.MoveFile strNewPath , strOldPath


But that doesn't help me either. Get a "File not found" error.. If i want to move the entire directory (omit the filenames) it doesn't work either. Any suggestions on how to go about this..? Heeeeelp..! [&:] Thanks..!

0 Comments   [ + ] Show comments

Answers (2)

Posted by: nheim 17 years ago
10th Degree Black Belt
0
Hi neo,
first of all: Set wshshell = WScript.CreateObject("WScript.Shell") won't work on vbs called in MSI.
Use: Set wshshell = CreateObject("WScript.Shell") instead of.

Please specify exactly, how and where you call this script.

What happens, if you insert a messagebox statement into the script?

Regards, Nick
Posted by: Flakes 17 years ago
Senior Yellow Belt
0
Fso.MoveFile strNewPath , strOldPath


the syntax is : object.MoveFile ( source, destination )



So shouldn't that be : Fso.MoveFile strOldPath,strNewPath

??

To handle spaces in the path you could try this :

strOldPath ="""" & "C:\Program Files\Microsoft Office\OFFICE11\Library\Analysis\ATPVBAEN.XLA" & """"


*Might* Work !!
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
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