Solved

vbs move file script error "Expected end of Statement"

Posted on 2011-03-09
5
1,529 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the major drawbacks of deploying applications by GPO is the complete lack of any centralized reporting. After a normal deployment, there are two ways to find out if it was successful – by looking in the event log, and by looking in the log of…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

751 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