Solved

vbs move file script error "Expected end of Statement"

Posted on 2011-03-09
5
1,458 Views
Last Modified: 2012-05-11
Hi all,

After Installing an app through an MSI need to move a file from the InstallDIR to another folder. To do so, I'm trying a very simple VBS script built as a Custom Action into the MSI. When running this script manually (after the app has been installed) it works nicely, but when ran from the msi I'm getting error:
Error 1720. There is a problem with this Windows Installer Package. A script required for this install to complete could not be run. Contact your support personnel or package vendor. Custom action CA_MoveMmapFile script error -2146827263, Microsoft VBScript compilation error: Expected end of statement, Line 2, Column 82, objFSO.MoveFile "C:\Program Files\Mindjet\MindManager 8\MM8 New Map.mmap" , "C:\Documents and Settings\All Users\Templates\"

The code I'm using is this:
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.MoveFile "C:\Program Files\Mindjet\MindManager 8\MM8 New Map.mmap" , "C:\Documents and Settings\All Users\Templates\"

Open in new window


I have also tried:
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.MoveFile "C:\Program Files\Mindjet\MindManager 8\MM8 New Map.mmap" , "C:\Documents and Settings\All Users\Templates\"

Open in new window


Adding End Sub at the end of either code gives the same error.
0
Comment
Question by:Sergio_Apodaca
  • 2
  • 2
5 Comments
 
LVL 4

Assisted Solution

by:Tuyau2poil
Tuyau2poil earned 250 total points
ID: 35087866
can you try with more simple folder and without slash at end of second path:
example :
objFSO.MoveFile "C:\Program Files\Mindjet\MindManager 8\MM8 New Map.mmap" , "C:\temp"

it seems that your script is truncated during MSI execution, column 82 is just after "C:\" as if "Documents and Settings\All Users\Templates\" was a bad syntaxe or something else  (it's not but I try to understand...)
0
 
LVL 65

Assisted Solution

by:RobSampson
RobSampson earned 250 total points
ID: 35088042
Without the slash, it will try to create the *file* C:\temp and if the folder exists, will produce an error.

This code really should work....it's quite simple.....

What if you try this.

Rob.
Set objFSO = CreateObject("Scripting.FileSystemObject")
strFile = "C:\Program Files\Mindjet\MindManager 8\MM8 New Map.mmap"
strDestination = "C:\Documents and Settings\All Users\Templates\" 
objFSO.MoveFile strFile, strDestination

Open in new window

0
 

Accepted Solution

by:
Sergio_Apodaca earned 0 total points
ID: 35088301
It seems that for some reason the object MoveFile is not recognized appropriately by InstallShield. After trying some options, I used the Move (instead of MoveFile) while declaring as a variable the source path. It ended being like this:

Dim objFSO, fileTomove
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set fileTomove = objFSO.GetFile("C:\Program Files\Mindjet\MindManager 8\MM8 New Map.mmap")
fileTomove.Move("C:\Documents and Settings\All Users\Templates\")

Open in new window


It worked great. Thanks all for your comments!
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 35088347
Cool.  One thing to note though, Move doesn't overwrite, so either copy the source, then delete it, or delete the destination, then move it.

Rob.
Dim objFSO, fileTomove
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set fileTomove = objFSO.GetFile("C:\Program Files\Mindjet\MindManager 8\MM8 New Map.mmap")
fileTomove.Copy("C:\Documents and Settings\All Users\Templates\", True)
fileTomove.Delete True

Open in new window

0
 

Author Closing Comment

by:Sergio_Apodaca
ID: 35126405
Even though the comments did not gave me the answer, they did pointed me in the right direction

Thank you all!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Welcome, welcome!  If you are new to the series and haven't been following along, please take a brief moment to review the first three installments: Part 1 (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/A_266-VBScri…
Among others, I monitor the Windows Installer zone and Installer zone. I find that many of the questions could be answered much more quickly if a Windows Installer verbose log were submitted with the question.   However, I do not always have t…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now