Jump to content











Photo
* * - - - 1 votes

VistaPE API - CopyProgram a single file


  • Please log in to reply
8 replies to this topic

#1 booty#1

booty#1

    Frequent Member

  • .script developer
  • 285 posts
  • Location:Near Frankfurt
  •  
    Germany

Posted 22 February 2008 - 10:23 AM

Hi,

for getting familiar with the current VistaPE scripting API I tried to update my Acronis Trueimage 10 script. While doing so I was confronted with a limitation of the VistaPE API I could not circumvent:

The main program consists of one EXE and several DLLs present in the source folder - but the source folder does contain more files as needed. I don't want to delete files from the source folder, therefore I want to copy each needed file to the program directory using the VistaPE API command CopyProgram as this looks like the only command for accessing the program installation directory (that repects the "ForceAllToRam" setting).
The relevant parts of my script are looking as follows:
[Variables]

%ProgramTitle%=Acronis TrueImage 10

%ProgramEXE%=TrueImage.exe

%ProgramFolder%=TrueImage10



[Process]

RunFromRam, %pCheckBox1%

CopyProgram,"%pFileBox1%\TrueImage.exe"

The problem is that executing this script fails with the following mesage:

Success  IF - File does not exist: [D:\temp\VistaPE AcronisTrueImage\TrueImage.exe\TrueImage.exe] executing command:   Message,The path you specified as your source is not valid! Please select a valid source dir in the script configuration window...

 Success  Message: The path you specified as your source is not valid! Please select a valid source dir in the script configuration window...

 Success  IF - File does not exist: [D:\temp\VistaPE AcronisTrueImage\TrueImage.exe\TrueImage.exe] executing command: Exit,Exiting...

Is there any alternative alternative for CopyProgram that isn able to copy one file only?

booty#1

#2 Arvy

Arvy

    Frequent Member

  • Developer
  • 430 posts
  • Location:Canada, Parry Sound
  • Interests:IT, Outdoors, Horses
  •  
    Canada

Posted 22 February 2008 - 12:12 PM

Is should be possible to use the normal FileCopy command with the %Target_Prog% variable. Does that not work properly in this case?

#3 pedrole15

pedrole15

    Silver Member

  • .script developer
  • 731 posts
  •  
    France

Posted 22 February 2008 - 12:49 PM

CopyProgram,"%pFileBox1%\TrueImage.exe"
must be
CopyProgram,"%pFileBox1%"
param 1 must be a directory not a filename

#4 booty#1

booty#1

    Frequent Member

  • .script developer
  • 285 posts
  • Location:Near Frankfurt
  •  
    Germany

Posted 22 February 2008 - 12:58 PM

Is should be possible to use the normal FileCopy command with the %Target_Prog% variable. Does that not work properly in this case?

True, that should be the right variable (I did not recognize that by the VistaPE documentation), but even if it works, simply copying a file is not the same as CopyProgram does.

booty#1

#5 pedrole15

pedrole15

    Silver Member

  • .script developer
  • 731 posts
  •  
    France

Posted 22 February 2008 - 01:18 PM

True, that should be the right variable (I did not recognize that by the VistaPE documentation), but even if it works, simply copying a file is not the same as CopyProgram does.

booty#1

that's why i have retouch the api
all setting are set by RunFromRam
I have send this new api to NightMan and Avry
I am not at home now so if you want try ask Avry to send it to you
Pedro

#6 Arvy

Arvy

    Frequent Member

  • Developer
  • 430 posts
  • Location:Canada, Parry Sound
  • Interests:IT, Outdoors, Horses
  •  
    Canada

Posted 22 February 2008 - 01:25 PM

True, that should be the right variable (I did not recognize that by the VistaPE documentation), but even if it works, simply copying a file is not the same as CopyProgram does.

Sorry, I must have misunderstood. I thought you were looking for a way to copy only a single file into the program folder. But, if you want an alternative to CopyProgram for copying the contents of an entire directory into the program folder, you should also be able to use DirCopy with the %Target_Prog% variable.

The CopyProgram command logic for doing essentially the same thing (using %Target_Prog% along with %ProgramFolder% and other application script variables) is defined by VistaPE's api.script as follows:
#copy source folder

[Copy_Program]

#check run from ram

IniRead,%VistaInfo%,"VistaInfo","ForceAllToRam","%ForceAllToRam%"

If,"%ForceAllToRam%",Equal,"Yes",Set,"%Target_Prog%","%TargetDir%\Program#$sFiles"

Echo,"Copy program files..."

#destination folder

If,#2,Equal,,Set,%Target%,%Target_Prog%\%ProgramFolder%

If,#2,NotEqual,,Set,%Target%,#2

#executable

If,#3,Equal,,Set,#3,%ProgramExe%

System,RefreshVars

If,NotExistFile,"#1\#3",Message,"The path you specified as your source is not valid! #$x#$xPlease select a valid source dir in the script configuration window..."

If,NotExistFile,"#1\#3",Exit,"Exiting..."

ShellExecute,hide,"%WindowsDir%\System32\cmd.exe","/c mkdir #$q%Target%#$q"

DirCopy,"#1\*.*","%Target%"

If I'm still not understanding you correctly, I guess you'll have to spell out your actual requirements for me in more detail. Some days I'm a little dense and this may be one of them. :)

#7 booty#1

booty#1

    Frequent Member

  • .script developer
  • 285 posts
  • Location:Near Frankfurt
  •  
    Germany

Posted 22 February 2008 - 01:37 PM

Sorry, I must have misunderstood. I thought you were looking for a way to copy only a single file into the program folder.

That is exactly what I want to do. I tried to use a FileCopy to %Target_Prog%\%ProgramFolder% but the file is always copied to the Programs directory whether I execute RunFromRam true or false before.

booty#1

#8 Arvy

Arvy

    Frequent Member

  • Developer
  • 430 posts
  • Location:Canada, Parry Sound
  • Interests:IT, Outdoors, Horses
  •  
    Canada

Posted 22 February 2008 - 02:02 PM

That is exactly what I want to do. I tried to use a FileCopy to %Target_Prog%\%ProgramFolder% but the file is always copied to the Programs directory whether I execute RunFromRam true or false before.

Hmmm. Looks like you may have discovered a flaw in the VistaPE API logic. It really should switch %Target_Prog% automatically. But, since it doesn't, I can only suggest that you borrow the relevant logic from the CopyProgram command and add it to your own script where needed:
IniRead,%VistaInfo%,"VistaInfo","ForceAllToRam","%ForceAllToRam%"

If,"%ForceAllToRam%",Equal,"Yes",Set,"%Target_Prog%","%TargetDir%\Program#$sFiles"

Having done that, you should then be able to use the FileCopy command with the %Target_Prog% variable as originally suggested. Also, as pedrole15 suggested above, I've passed along to you via PM a copy of his API updates to try. I've only tested them with VistaPE v.11, but they seem to work very well.

#9 online

online

    Silver Member

  • Advanced user
  • 767 posts

Posted 22 February 2008 - 03:15 PM

the file is always copied to the Programs directory

That occurs because you have set "%ProgramFolder%" variable...

To solve the issue let that variable empty as following

%ProgramFolder%=

then add further variables as following

[Variables]

%ProgramFolder%=

%ProgramEXE%=%TargetDir%\%DestDir%\TrueImage\TrueImage.exe

%ProgramTitle%=TrueImage

				   

[Process]

Echo,Processing %ProgramTitle%...

RunFromRam,%pCheckBox1%

IniRead,%VistaInfo%,"VistaInfo","BuildModel","%BuildModel%"

If,"%BuildModel%",Equal,"RAM",Set,"%DestDir%","Program#$sFiles"

If,"%BuildModel%",Equal,"Normal",Set,"%DestDir%","Programs"

IniRead,%VistaInfo%,"VistaInfo","ForceAllToRam","%ForceAllToRam%"

If,"%ForceAllToRam%",Equal,"Yes",Set,"%DestDir%","Program#$sFiles"

If,"%ForceAllToRam%",Equal,"No",Set,"%DestDir%","Programs"

If,%pCheckBox1%,Equal,True,Set,"%DestDir%","Program#$sFiles"

If,%pCheckBox1%,Equal,False,Set,"%DestDir%","Programs"

(probably the last two lines are redundant, but however I like add those...)


Then you can add every single file you want to copy as following

FileCopy,"%pFileBox1%\TrueImage.exe","%TargetDir%\%DestDir%\TrueImage"
or
FileCopy,"%pFileBox1%\Drivers\snapapi.dll","%target_sys%\drivers"


Btw: be aware that the path you specified as your source is something like the following

"\Program Files\Acronis\TrueImageHome\BartPE\Files"


Btw2: an alternative could be to encode your files in a "7z" archive and then create a new script with the same above notes in order to extract it in right location...

Unpack,Folder,TIB.7z,,%TargetDir%\%DestDir%\TrueImage
Really in that last case you could need two "7z" archives in order to encode also "Drivers" folder content in "System32\drivers"
Unpack,Folder,drivers.7z,,%target_sys%\drivers
if you will encode in one archive all single files
or
Unpack,Folder,sys32.7z,,%target_sys%
if you will encode in one archive "system32\drivers" folder containing all needed files...




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users