Dashut
Posts: 142
Joined: Tue May 04, 2010 4:41 pm

Problem with xcopy and CreateExeProcess

Using AI 7.7:
I have started using successfully your custom action CreateExeProcess as explained here: http://www.advancedinstaller.com/user-g ... indow.html for hiding my custom actions.
However, for one specific custom action: "xcopy" it just doesn't work! I've tried various combinations, but nothing works.
I want to use xcopy to backup some directory before the installation copies files, but I can't seem to understand why it's not working.
If I replace the xopy command with "notepad.exe" I can see that all parameters are passed correctly and everything should be okay, but God knows why this is just not working (and as I mentioned: I'm using this successfully with other things I'm trying to do "hidden").

I'm using it like so:

Code: Select all

Source Path: <AI_CUSTACTS>aicustact.dll
Source Type: Dynamic linked library (*.dll)
Function name: CreateExeProcess
Action Data: xcopy /C /Q /Y "c:\php\php.ini" "c:\backup\"
When I put in "Action Data:" for example: notepad.exe "hello world"
it works. If I put anything else other than what I'm trying to do with xcopy: it works. Only xcopy doesn't work...
If I try to copy/paste the "Action Data" command from the msi log to a command prompt window: it works! (meaning: the command should have also worked with CreateExeProcess)

I tried also:
xcopy.exe /C /Q /Y "c:\php\php.ini" "c:\backup\"
I also tried:
c:\windows\system32\xcopy.exe /C /Q /Y "c:\php\php.ini" "c:\backup\"
but no combination seemed to work.
I also tried:
cmd.exe /K c:\windows\system32\xcopy.exe /C /Q /Y "c:\php\php.ini" "c:\backup\"
and various places to put quotation marks: but nothing works...

I've moved this command (xcopy) back to "launch file or open URL", and it works! but now the command prompt is shown... and waiting for you help so that I can hide this window again.
I suspect that something in CreateExeProcesss is "sensitive" to the parameters passed and this fails (or something else, but definitely it has to do with CreateExeProcess, since as you can see I manage to make it work with "Launch File or Open URL").
Your help will be greatly appreciated. Dashut.
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Problem with xcopy and CreateExeProcess

Hi,

This happens because xcopy requires many command line parameters. Most likely the parameters cannot be parsed correctly by the Windows API we are using.

However, you have the following solution to run a bat file with the hidden window:
-- create .vbs file with the following content:

Code: Select all

CreateObject("WScript.Shell").Run """" & WScript.Arguments(0) & """", 0, False
-- then create a .bat file with your code:

Code: Select all

xcopy /C /Q /Y "c:\php\php.ini" "c:\backup\"
-- now add them as temporary files in the Files and Folders page
-- go to Custom Actions page and add a "Launch File or Open URL" custom action
-- set it Command Line field to :

Code: Select all

"[&LaunchBatHidden.vbs]" "[&myCommand.bat]"
using the [Edit] button

This should had the same effect and can be used for any BAT file you wish. Please note that the custom action must be executed after the standard action "MigrateFeatureStates" in order for the paths of the temporary files to be correctly resolved.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
phlow666
Posts: 144
Joined: Thu Jan 27, 2011 8:10 am
Location: Germany

Re: Problem with xcopy and CreateExeProcess

Hello,
is it also possible to have more than one parameter (some extra parameters for the batchfile)?

For example like:

Code: Select all

"[&LaunchBatHidden.vbs]" "[&myCommand.bat]" "[BatchParam1]" "[BatchParam2]"
The BatchParams must be like [AppDir].
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Problem with xcopy and CreateExeProcess

Hi,

Theoretically it's doable, but it won't look very nice. Basically, you need to modify the VBScript to use all the arguments instead of just WScript.Arguments(0). Why not use a file copy operation instead?

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
phlow666
Posts: 144
Joined: Thu Jan 27, 2011 8:10 am
Location: Germany

Re: Problem with xcopy and CreateExeProcess

Hello,
I tried it, but it unfortunatelly don't works.
Here is my scenario:

I have in one mergemodule (mainmodule) a folder with common plugins. In an other mergemodule I need the same folder. I added the operation described in this thread http://www.advancedinstaller.com/forums ... =2&t=19613.

Could it be maybe a timing problem? When I install the other mergemodule later it will copy the files. Any suggestions?
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Problem with xcopy and CreateExeProcess

Hi,

I'm not sure why the copy operation doesn't work. Can you please send us the .AIP (project) files you are using to support at advancedinstaller dot com so we can investigate them?

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
phlow666
Posts: 144
Joined: Thu Jan 27, 2011 8:10 am
Location: Germany

Re: Problem with xcopy and CreateExeProcess

Ok,
logfiles sent.
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Problem with xcopy and CreateExeProcess

Hi,

You were right, it's a timing problem. A file copy operation doesn't work in your case (copying files installed by the current process).

Back to xcopy. In your VBScript you can try executing this command line:

Code: Select all

CreateObject("WScript.Shell").Run """" & WScript.Arguments.Item(0) & """ " & """" & WScript.Arguments.Item(1) & """ " & """" & WScript.Arguments.Item(2) & """"
Item(0) represents the BAT file path and the other Item elements are the BAT parameters.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”