Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

vbs move file script error "Expected end of Statement"

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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

I have been scripting applications way too long and can never remember how to create an ISS file.  So I decided to write this article to act as my own knowledge base for future reference, and hope you will also benefit. An ISS file is a response …
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

722 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