Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

vbs move file script error "Expected end of Statement"

Posted on 2011-03-09
5
Medium Priority
?
1,608 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 1000 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 1000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

One of the most frequently asked questions on EE in the "Windows Installer" zone is how to eliminate self-triggered installation of some product.  The problem occurs when, suddenly, whenever a certain application is launched, or even when a folder i…
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
Screencast - Getting to Know the Pipeline
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

824 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