Solved

vbs move file script error "Expected end of Statement"

Posted on 2011-03-09
5
1,555 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

Enroll in July's Course of the Month

July's Course of the Month is now available! Enroll to learn HTML5 and prepare for certification. It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
Monitor input from a computer is usually nothing special.  In this instance it prevented anyone from using the computer.  This was a preconfiguration that didn't work.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

624 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