Jump to content











Photo
* * * * * 1 votes

App scripts


  • Please log in to reply
659 replies to this topic

#1 Nuno Brito

Nuno Brito

    Platinum Member

  • .script developer
  • 10544 posts
  • Location:boot.wim
  • Interests:I'm just a quiet simple person with a very quiet simple life living one day at a time..
  •  
    European Union

Posted 25 July 2007 - 03:45 PM

Hi everyone!

We've already discussed previously the introduction of a new API to be used inside scripts.

Over the last months it became more visible that a more universal and project independent way to create scripts that can add programs inside our projects needs to be used.

So far we've been creating scripts that were written specifically for nativeEx or LiveXP or BartPECore, but why rewrite a script since most tasks are simply repeated across projects and need to make different scripts that add the same program? :yahoo:


To solve this matter a simple set of functions can be used and made available to all scripts across all currently developed projects and the future ones to come. This way your application scripts will still work even when you use another project.

Before, a script would need to adapt to work under a specific project

Now, projects can adapt to work with these scripts and we get an very big ammount of possible scripts to use inside any project that adds support for this method.

Please note - this doesn't mean that projects need to work exclusively with this API method - just need to add a few variables that are recognized by these scripts. All scripts that were specifically written to work with a specific will still work as well as before..


I am posting the changes that should be made for this method to work with LiveXP, NativeEx and NativePE projects.

It should soon be adapted for other projects and the concept remains the same - we use variables instead of fixed names and this way make everything work in a more "universal" way which is valid for most common cases when we want to add a program inside a project.


Add on script.project:

[variables]%api%=%projectdir%\Basic\Build\api.scriptAdd_Shortcut=Run,%api%,AddShortcutRequire_File=run,%api%,expand_fileUnpack=Run,%api%,depack%source_win%=%SourceDir%\I386%target_win%=%targetDir%\I386%source_sys%=%SourceDir%\I386%target_sys%=%TargetDir%\I386\System32%HIVE_HKLM%=%targetDir%\I386\System32\setupreg.hiv%HIVE_HKCU%=%TargetDir%\i386\System32\Config\default%HIVE_HKU%=%targetDir%\I386\System32\Config\software%HIVE_BASE%=HKLM%reg_temp%=wb-hive%reg%\=%reg_temp%\hive_load=run,%api%,reg_hiveloadhive_unload=run,%api%,reg_hiveunloadreg_add=RegWrite,"%HIVE_BASE%"associate_file=run,%api%,do_associate
This api.script can be placed anywhere you wish but we've defined %api% with the value "%projectdir%\Basic\Build\api.script" inside script.project so it should be placed by default inside the Basic\Build folder.The above settings might seem a bit complicated, but they are also meant as reference for those who maintain our script projects - by default - most .script developers and everyone else who wishes to write a script won't ever need to worry about them and only needs to know which functions can be used inside their scripts.Proper documentation to explain all this still needs to be elaborated, but here is a small set of demonstration commands that show the scope of possible actions
[Process]Echo,"Making new directories.."IniRead,"%ProjectInfo%","TargetStrings","sProgram_Files",%WorkDir%DirMake,%targetDir%\%workDir%\dixml// Add shortcutsIf,%pCheckBox1%,Equal,True,Run,%BuildModelScript%,Add-Shortcut,"DE","#$pSystemDrive#$p\%workDir%\dixml\dixml.exe","DriveImage XML"Run,%BuildModelScript%,Add-Shortcut,"SM\Backup","#$pSystemDrive#$p\%workDir%\dixml\dixml.exe","DriveImage XML"Echo,"Extract files.."ExtractAllFiles,"%ScriptFile%","Folder","%targetDir%\%workDir%\dixml"Expand,"%SourceDir%\I386\APPHELP.DL_","%TargetDir%\i386\system32"Expand,"%SourceDir%\I386\LZ32.DL_","%TargetDir%\i386\system32"Expand,"%SourceDir%\I386\WOW32.DL_","%TargetDir%\i386\system32"Expand,"%SourceDir%\I386\NTVDM.EX_","%TargetDir%\i386\system32"Echo,"Loading registry hive: [%TargetDir%\i386\System32\Config\software]"RegHiveLoad,Tmp_software,%TargetDir%\i386\System32\Config\softwareEcho,"Writing new values on registry hive.."RegWrite,HKLM,0x1,"Tmp_software\Microsoft\Windows NT\CurrentVersion\Fonts","MS Sans Serif 8,10,12,14,18,24 (VGA res)","SSERIFE.FON"RegWrite,HKLM,0x1,"Tmp_software\Microsoft\Windows NT\CurrentVersion\Fonts","MS Serif 8,10,12,14,18,24 (VGA res)","SERIFE.FON"RegWrite,HKLM,0x1,"Tmp_software\Microsoft\Windows NT\CurrentVersion\Fonts","Small Fonts (VGA res)","SMALLE.FON"RegWrite,HKLM,0x1,"Tmp_software\Classes\CLSID\{43A8F463-4222-11d2-B641-006097DF5BD4}","","Shell Name Space ListView"RegWrite,HKLM,0x2,"Tmp_software\Classes\CLSID\{43A8F463-4222-11d2-B641-006097DF5BD4}\InProcServer32","","%SystemRoot%\System32\shdocvw.dll"RegWrite,HKLM,0x1,"Tmp_software\Classes\CLSID\{43A8F463-4222-11d2-B641-006097DF5BD4}\InProcServer32","ThreadingModel","Apartment"RegWrite,HKLM,0x1,"Tmp_software\Classes\CLSID\{603D3800-BD81-11d0-A3A5-00C04FD706EC}","","Background Task Scheduler"RegWrite,HKLM,0x2,"Tmp_software\Classes\CLSID\{603D3800-BD81-11d0-A3A5-00C04FD706EC}\InProcServer32","","%SystemRoot%\System32\browseui.dll"RegWrite,HKLM,0x1,"Tmp_software\Classes\CLSID\{603D3800-BD81-11d0-A3A5-00C04FD706EC}\InProcServer32","ThreadingModel","Apartment"RegWrite,HKLM,0x1,"Tmp_software\Classes\CLSID\{13709620-C279-11CE-A49E-444553540000}","","Shell Automation Service"RegWrite,HKLM,0x2,"Tmp_software\Classes\CLSID\{13709620-C279-11CE-A49E-444553540000}\InProcServer32","","%SystemRoot%\system32\SHELL32.dll"RegWrite,HKLM,0x1,"Tmp_software\Classes\CLSID\{13709620-C279-11CE-A49E-444553540000}\InProcServer32","ThreadingModel","Apartment"RegWrite,HKLM,0x1,"Tmp_software\Classes\CLSID\{13709620-C279-11CE-A49E-444553540000}\ProgID","","Shell.Application.1"RegWrite,HKLM,0x1,"Tmp_software\Classes\CLSID\{13709620-C279-11CE-A49E-444553540000}\TypeLib","","{50a7e9b0-70ef-11d1-b75a-00a0c90564fe}"RegWrite,HKLM,0x1,"Tmp_software\Classes\CLSID\{13709620-C279-11CE-A49E-444553540000}\Version","","1.1"RegWrite,HKLM,0x1,"Tmp_software\Classes\CLSID\{13709620-C279-11CE-A49E-444553540000}\VersionIndependentProgID","","Shell.Application"RegWrite,HKLM,0x1,"Tmp_software\Classes\Shell.Application","","Shell Automation Service"RegWrite,HKLM,0x1,"Tmp_software\Classes\Shell.Application\CLSID","","{13709620-C279-11CE-A49E-444553540000}"RegWrite,HKLM,0x1,"Tmp_software\Classes\Shell.Application\CurVer","","Shell.Application.1"RegWrite,HKLM,0x1,"Tmp_software\Classes\Shell.Application.1","","Shell Automation Service"RegWrite,HKLM,0x1,"Tmp_software\Classes\Shell.Application.1\CLSID","","{13709620-C279-11CE-A49E-444553540000}"RegHiveUnLoad,Tmp_software
After
[variables]%ProgramTitle%=DriveImage XML%ProgramEXE%=dixml.exe%ProgramFolder%=DriveImageXML[process]If,%pCheckBox1%,Equal,True,Add_Shortcut,DesktopAdd_Shortcut,StartMenuunpackecho,"Expanding DLLs..."require_file,APPHELP.DLLrequire_file,LZ32.DLLrequire_file,WOW32.DLLrequire_file,NTVDM.EXEhive_load,HKUreg_add,0x1,"%reg%\Microsoft\Windows NT\CurrentVersion\Fonts","MS Sans Serif 8,10,12,14,18,24 (VGA res)","SSERIFE.FON"reg_add,0x1,"%reg%\Microsoft\Windows NT\CurrentVersion\Fonts","MS Serif 8,10,12,14,18,24 (VGA res)","SERIFE.FON"reg_add,0x1,"%reg%\Microsoft\Windows NT\CurrentVersion\Fonts","Small Fonts (VGA res)","SMALLE.FON"reg_add,0x1,"%reg%\Classes\CLSID\{43A8F463-4222-11d2-B641-006097DF5BD4}","","Shell Name Space ListView"reg_add,0x2,"%reg%\Classes\CLSID\{43A8F463-4222-11d2-B641-006097DF5BD4}\InProcServer32","","%SystemRoot%\System32\shdocvw.dll"reg_add,0x1,"%reg%\Classes\CLSID\{43A8F463-4222-11d2-B641-006097DF5BD4}\InProcServer32","ThreadingModel","Apartment"reg_add,0x1,"%reg%\Classes\CLSID\{603D3800-BD81-11d0-A3A5-00C04FD706EC}","","Background Task Scheduler"reg_add,0x2,"%reg%\Classes\CLSID\{603D3800-BD81-11d0-A3A5-00C04FD706EC}\InProcServer32","","%SystemRoot%\System32\browseui.dll"reg_add,0x1,"%reg%\Classes\CLSID\{603D3800-BD81-11d0-A3A5-00C04FD706EC}\InProcServer32","ThreadingModel","Apartment"reg_add,0x1,"%reg%\Classes\CLSID\{13709620-C279-11CE-A49E-444553540000}","","Shell Automation Service"reg_add,0x2,"%reg%\Classes\CLSID\{13709620-C279-11CE-A49E-444553540000}\InProcServer32","","%SystemRoot%\system32\SHELL32.dll"reg_add,0x1,"%reg%\Classes\CLSID\{13709620-C279-11CE-A49E-444553540000}\InProcServer32","ThreadingModel","Apartment"reg_add,0x1,"%reg%\Classes\CLSID\{13709620-C279-11CE-A49E-444553540000}\ProgID","","Shell.Application.1"reg_add,0x1,"%reg%\Classes\CLSID\{13709620-C279-11CE-A49E-444553540000}\TypeLib","","{50a7e9b0-70ef-11d1-b75a-00a0c90564fe}"reg_add,0x1,"%reg%\Classes\CLSID\{13709620-C279-11CE-A49E-444553540000}\Version","","1.1"reg_add,0x1,"%reg%\Classes\CLSID\{13709620-C279-11CE-A49E-444553540000}\VersionIndependentProgID","","Shell.Application"reg_add,0x1,"%reg%\Classes\Shell.Application","","Shell Automation Service"reg_add,0x1,"%reg%\Classes\Shell.Application\CLSID","","{13709620-C279-11CE-A49E-444553540000}"reg_add,0x1,"%reg%\Classes\Shell.Application\CurVer","","Shell.Application.1"reg_add,0x1,"%reg%\Classes\Shell.Application.1","","Shell Automation Service"reg_add,0x1,"%reg%\Classes\Shell.Application.1\CLSID","","{13709620-C279-11CE-A49E-444553540000}"hive_unload,HKU
Other app script examplesSmartFTP
[variables]%ProgramTitle%=SmartFTP%ProgramEXE%=SmartFTP.exe%ProgramFolder%=SmartFTP[process]Add_Shortcut,StartMenuunpackrequire_file,APPHELP.DLLrequire_file,ATL.DLLrequire_file,CLBCATQ.DLLrequire_file,COMRES.DLLrequire_file,CREDUI.DLLrequire_file,CRYPT32.DLLrequire_file,CSCDLL.DLLrequire_file,CSCUI.DLLrequire_file,HNETCFG.DLLrequire_file,IMGUTIL.DLLrequire_file,IPHLPAPI.DLLrequire_file,MFC42.DLLrequire_file,MLANG.DLLrequire_file,MSASN1.DLLrequire_file,MSHTML.DLLrequire_file,MSIMTF.DLLrequire_file,MSLS31.DLLrequire_file,MSV1_0.DLLrequire_file,MSWSOCK.DLLrequire_file,MSXML3.DLLrequire_file,NETSHELL.DLLrequire_file,OLEACC.DLLrequire_file,PNGFILT.DLLrequire_file,RASADHLP.DLLrequire_file,RASAPI32.DLLrequire_file,RASMAN.DLLrequire_file,RICHED20.DLLrequire_file,RICHED32.DLLrequire_file,RSAENH.DLLrequire_file,RTUTILS.DLLrequire_file,SHDOCVW.DLLrequire_file,WSHTCPIP.DLL



Reg Shot

[variables]%ProgramTitle%=RegShot%ProgramEXE%=RegShot.exe%ProgramFolder%=RegShot[process]Add_Shortcut,StartMenuunpack


This is not meant to apply for all programs nor is meant to become a "perfect" method - but will make your life simpler when you want to create a new script - there's even a tutorial explaining how this can quickly be done here


Also look inside other scripts already coded with this method under the download section here.


Things may change as we continue our improvements but at least this way you get a good way to write your scripts for a much wider variety of projects - more documentation to follow soon..


How important is this for overall scripting?

Makes things simpler and so much more flexible that we can improve and change our favourite projects and still use all available scripts over the next years to come.

:)

#2 pedrole15

pedrole15

    Silver Member

  • .script developer
  • 731 posts
  •  
    France

Posted 25 July 2007 - 10:24 PM

Nuno i think you must correct this :

echo,"API - Creating a new shortcut for %programTitle%.. [%programFolder%\%programExe%]"If,#1,Equal,,Set,"%shortcut_type%","SM"If,#1,Equal,Desktop,Set,"%shortcut_type%","DE"If,#1,Equal,StartMenu,Set,"%shortcut_type%","SM"If,#1,Equal,QuickLaunch,Set,"%shortcut_type%","QL"If,#1,Equal,AutoStart,Set,"%shortcut_type%","AU"If,#2,Equal,,StrFormat,filename,%Scriptdir%,#2Run,%BuildModelScript%,Add-Shortcut,"%shortcut_type%\#2","#$pProgramFiles#$p\%programFolder%\%programExe%","%ProgramTitle%","-SW:#$pProgramFiles#$p\%programFolder%"
by
echo,"API - Creating a new shortcut for %programTitle%.. [%programFolder%\%programExe%]"If,#1,Equal,,Set,"%shortcut_type%","SM"If,#1,Equal,Desktop,Set,"%shortcut_type%","DE"If,#1,Equal,StartMenu,Set,"%shortcut_type%","SM"If,#1,Equal,QuickLaunch,Set,"%shortcut_type%","QL"If,#1,Equal,AutoStart,Set,"%shortcut_type%","AU"If,#2,Equal,,StrFormat,filename,%Scriptdir%,#2If,%shortcut_type%,Equal,"SM",Run,%BuildModelScript%,Add-Shortcut,"%shortcut_type%\#2","#$pProgramFiles#$p\%programFolder%\%programExe%","%ProgramTitle%","-SW:#$pProgramFiles#$p\%programFolder%"If,%shortcut_type%,NotEqual,"SM",Run,%BuildModelScript%,Add-Shortcut,"%shortcut_type%","#$pProgramFiles#$p\%programFolder%\%programExe%","%ProgramTitle%","-SW:#$pProgramFiles#$p\%programFolder%"
Because we don't have to make a folder on Desktop

#3 Nuno Brito

Nuno Brito

    Platinum Member

  • .script developer
  • 10544 posts
  • Location:boot.wim
  • Interests:I'm just a quiet simple person with a very quiet simple life living one day at a time..
  •  
    European Union

Posted 25 July 2007 - 10:44 PM

Hi Pedrole15!

Funny you mention it - but shouldn't we be able to create folders on the desktop if needed? :yahoo:

I've also modified this function today to support creating icons using other executables and parameters, but it's not yet finished (it works as expected, but can be simplified to run faster)

[AddShortcut]echo,""If,#1,Equal,,Set,"%shortcut_type%","SM"If,#1,Equal,Desktop,Set,"%shortcut_type%","DE"If,#1,Equal,StartMenu,Set,"%shortcut_type%","SM"If,#1,Equal,QuickLaunch,Set,"%shortcut_type%","QL"If,#1,Equal,AutoStart,Set,"%shortcut_type%","AU"If,#2,Equal,,StrFormat,filename,%Scriptdir%,#2Set,"%My_Shortcut_FOLDER%",#$pProgramFiles#$p\%programFolder%Set,"%My_Shortcut_EXE%","%My_Shortcut_FOLDER%\%programExe%"If,#3,NotEqual,,Set,"%My_Shortcut_EXE%","#3"If,#3,NotEqual,,StrFormat,path,#3,%My_Shortcut_FOLDER%System,RefreshVarsRun,%BuildModelScript%,Add-Shortcut,"%shortcut_type%\#2","%My_Shortcut_EXE%#4","%ProgramTitle%","-SW:%My_Shortcut_FOLDER%"
One can use the new function to add icons to files which are by default placed in other folders or even available from the %path% environment variables.The first parameter on "Add_Shortcut,StartMenu,,MSHEARTS.EXE" is empty because it's reserved to define the startmenu folder, and this way we can leave it as default script folder location following your tip.. :)btw: Peter also suggested to read the value of the title key inside each script.project - what do you think about this idea? It would also keep compatibility of folder names with the download center even when using localized titles for start menu and such.. :)
[variables]%ProgramTitle%=Hearts%ProgramEXE%=MSHEARTS.EXE%ProgramFolder%=MS_Hearts[process]Echo,"Create a shortcut.."Add_Shortcut,StartMenu,,MSHEARTS.EXErequire_file,mshearts.exerequire_file,mshearts.hlprequire_file,mshearts.cntrequire_file,SHIMENG.DLLrequire_file,ACGENRAL.DLLrequire_file,CARDS.DLLrequire_file,SHIMENG.DLLrequire_file,HHCTRL.OCXrequire_file,MFC42U.DLL


#4 pedrole15

pedrole15

    Silver Member

  • .script developer
  • 731 posts
  •  
    France

Posted 25 July 2007 - 11:04 PM

I'am trying some tweak
[AddShortcut]echo,""echo,"API - Creating a new shortcut for %programTitle%.. [%programFolder%\%programExe%]"If,#1,Equal,,Set,"%shortcut_type%","DE"If,#1,Equal,Desktop,Set,"%shortcut_type%","DE"If,#1,Equal,StartMenu,Set,"%shortcut_type%","SM"If,#1,Equal,QuickLaunch,Set,"%shortcut_type%","QL"If,#1,Equal,AutoStart,Set,"%shortcut_type%","AU"If,#2,Equal,,StrFormat,filename,%Scriptdir%,#2If,#3,Equal,,Set,"%shortCut_Parameters%",""If,#3,NotEqual,,Set,"%shortCut_Parameters%","#$q#$s#$q-SP:%Parameters%"If,#4,Equal,,Set,"%shortCut_IconFile%",""If,#4,NotEqual,,Set,"%shortCut_IconFile%","#$q#$s#$q-SF:#$pProgramFiles#$p\%programFolder%\%IconFile%#$q#$s#$q-SI:0"If,#5,Equal,,Set,"%shortCut_Show%",""If,#5,Equal,"Max",Set,"%shortCut_Show%","#$q#$s#$q-SS:SW_SHOWMAXIMIZED"If,#5,Equal,"Min",Set,"%shortCut_Show%","#$q#$s#$q-SS:SW_SHOWMINIMIZED"If,#5,Equal,"Normal",Set,"%shortCut_Show%","#$q#$s#$q-SS:SW_SHOWNORMAL"If,%shortcut_type%,Equal,"SM",Run,%BuildModelScript%,Add-Shortcut,"%shortcut_type%\#2","#$pProgramFiles#$p\%programFolder%\%programExe%","%ProgramTitle%","-SW:#$pProgramFiles#$p\%programFolder%%shortCut_IconFile%%shortCut_Parameters%%shortCut_Show%"If,%shortcut_type%,NotEqual,"SM",Run,%BuildModelScript%,Add-Shortcut,"%shortcut_type%","#$pProgramFiles#$p\%programFolder%\%programExe%","%ProgramTitle%","-SW:#$pProgramFiles#$p\%programFolder%%shortCut_IconFile%%shortCut_Parameters%%shortCut_Show%"
and in the script
[variables]%ProgramTitle%=IrfanView%ProgramEXE%=i_view32.exe%ProgramFolder%=IrfanView%IconFile%=Pmagic.ico%Parameters%=i_view32.bmp[process]Add_Shortcut,Desktop,,%Parameters%,%IconFile%,MaxAdd_Shortcut,StartMenuunpackassociate_file,icoassociate_file,bmp
It 's working well and can be use with VistaPE with same syntax

#5 Nuno Brito

Nuno Brito

    Platinum Member

  • .script developer
  • 10544 posts
  • Location:boot.wim
  • Interests:I'm just a quiet simple person with a very quiet simple life living one day at a time..
  •  
    European Union

Posted 25 July 2007 - 11:43 PM

hmm.. good approach, are you available to start porting these api functions to vistape? :yahoo:


Let's see if we can make really simple and solid scripting so that others can learn quickly and lose the fear of applying them to their own application scripts.. :)



Your opinion and help implementing vistape support is really welcome - the more people involved the better we can output some really efficient work for the future script developers and all available projects. :)

#6 pscEx

pscEx

    Platinum Member

  • Team Reboot
  • 12707 posts
  • Location:Korschenbroich, Germany
  • Interests:What somebody else cannot do.
  •  
    European Union

Posted 26 July 2007 - 07:50 AM

hmm.. good approach, are you available to start porting these api functions to vistape? :yahoo:


Let's see if we can make really simple and solid scripting so that others can learn quickly and lose the fear of applying them to their own application scripts.. :)



Your opinion and help implementing vistape support is really welcome - the more people involved the better we can output some really efficient work for the future script developers and all available projects. :)

One suggestion to make it 100% complete:
To IconFile, add IconIndex.
If the .EXE has several icons this makes it possible to chose icon #2 or #3 ...

Peter

#7 Nuno Brito

Nuno Brito

    Platinum Member

  • .script developer
  • 10544 posts
  • Location:boot.wim
  • Interests:I'm just a quiet simple person with a very quiet simple life living one day at a time..
  •  
    European Union

Posted 26 July 2007 - 09:21 AM

Maybe you could help Peter, I've already added this icon index support while associating with files:

associate_file,html,icon,%systemroot%\System32\Shell32.dll,-153

Will look back on the buildmodel documentation and see how it can be implemented.. :yahoo:

#8 pscEx

pscEx

    Platinum Member

  • Team Reboot
  • 12707 posts
  • Location:Korschenbroich, Germany
  • Interests:What somebody else cannot do.
  •  
    European Union

Posted 26 July 2007 - 06:11 PM

Maybe you could help Peter, I've already added this icon index support while associating with files:
Will look back on the buildmodel documentation and see how it can be implemented.. :)

I do not want to prohibit you to look into the doc (it is really explained there :yahoo: ).
Every user should at least have had one look into doc (what do you think, how many did click the help button on buildModel?)
But you are very busy with other important things.

Include '-SI:<icon index> in the fourth parameter

Peter

#9 pscEx

pscEx

    Platinum Member

  • Team Reboot
  • 12707 posts
  • Location:Korschenbroich, Germany
  • Interests:What somebody else cannot do.
  •  
    European Union

Posted 26 July 2007 - 06:17 PM

Maybe it is too late for this suggestion.

In my opinion, to make a script more readable, the API functions should have a special 'design' which makes them visually different from 'normal' WB commands.

Just as a sample:

$Add_Shortcut$ instead of Add_Shortcut
(This is really a sample, not a suggestion of a solution. I personally do not like this 'symbol of capitalism and imperalism' :yahoo:)

Peter

#10 Nuno Brito

Nuno Brito

    Platinum Member

  • .script developer
  • 10544 posts
  • Location:boot.wim
  • Interests:I'm just a quiet simple person with a very quiet simple life living one day at a time..
  •  
    European Union

Posted 26 July 2007 - 07:01 PM

hmm.. maybe we should keep it as simple as possible - even special characters can spread havoc and chaos whenever someone uses #$s or #$p and others quit reading any further thinking that it's some kind of StarTrek klingon language... :yahoo: (my fault I know..)


I really appreciate that you've included all documentation inside an html file on buildmodel - if everyone did the same we'd sure be able to read things more often as needed.. :)

#11 pscEx

pscEx

    Platinum Member

  • Team Reboot
  • 12707 posts
  • Location:Korschenbroich, Germany
  • Interests:What somebody else cannot do.
  •  
    European Union

Posted 26 July 2007 - 07:13 PM

hmm.. maybe we should keep it as simple as possible - even special characters can spread havoc and chaos whenever someone uses #$s or #$p and others quit reading any further thinking that it's some kind of StarTrek klingon language... :yahoo: (my fault I know..)

What about API functions MUST be in CAPITAL LETTERS?
(With syntax error from WB if not?)

Peter

#12 Nuno Brito

Nuno Brito

    Platinum Member

  • .script developer
  • 10544 posts
  • Location:boot.wim
  • Interests:I'm just a quiet simple person with a very quiet simple life living one day at a time..
  •  
    European Union

Posted 26 July 2007 - 07:20 PM

They are variables - we'd be limiting other vars as well - but you can write them in upper case letters if you wish.

I use a similar syntax too

[codebox] require_file,SHIMENG.DLL require_file,ACGENRAL.DLL require_file,ACTIVEDS.DLL require_file,ADSLDPC.DLL require_file,DHCPCSVC.DLL require_file,CABINET.DLL require_file,CDFVIEW.DLL require_file,CERTCLI.DLL require_file,CREDUI.DLL require_file,CLUSAPI.DLL
require_file,DBGHELP.DLL
require_file,DEVMGR.DLL
[/codebox]

Helps when checking if these any new DLL to add is already listed.

:yahoo:

#13 pscEx

pscEx

    Platinum Member

  • Team Reboot
  • 12707 posts
  • Location:Korschenbroich, Germany
  • Interests:What somebody else cannot do.
  •  
    European Union

Posted 26 July 2007 - 07:42 PM

They are variables - we'd be limiting other vars as well - but you can write them in upper case letters if you wish.

I know, but the check is easy:

Anywhere you have a replacement mechanism.
At that place:
If AnsiStartsStr('%', <source>)
<target> := AnsiReplaceText(...
Else
<target> := AnsiReplaceStr(...
If <source> = <target>
<Error message>

Why not?

Peter

#14 Nuno Brito

Nuno Brito

    Platinum Member

  • .script developer
  • 10544 posts
  • Location:boot.wim
  • Interests:I'm just a quiet simple person with a very quiet simple life living one day at a time..
  •  
    European Union

Posted 26 July 2007 - 07:50 PM

Mostly because it would force people to use only UPPERCASING while lowercases are also good - we'd be shouting these commands all day long.. :yahoo:

#15 pscEx

pscEx

    Platinum Member

  • Team Reboot
  • 12707 posts
  • Location:Korschenbroich, Germany
  • Interests:What somebody else cannot do.
  •  
    European Union

Posted 26 July 2007 - 07:55 PM

Mostly because it would force people to use only UPPERCASING while lowercases are also good - we'd be shouting these commands all day long.. :yahoo:

You won! :)
But still I would prefer to have API functions visually be different from WB commands :)
Peter

#16 Nuno Brito

Nuno Brito

    Platinum Member

  • .script developer
  • 10544 posts
  • Location:boot.wim
  • Interests:I'm just a quiet simple person with a very quiet simple life living one day at a time..
  •  
    European Union

Posted 26 July 2007 - 08:34 PM

:yahoo:

Thank you! :)

#17 pedrole15

pedrole15

    Silver Member

  • .script developer
  • 731 posts
  •  
    France

Posted 26 July 2007 - 09:29 PM

How to make this work :
&#91;AddShortcut&#93;

...

If,%Parameters%,Equal,,Set,&#34;%shortCut_Parameters%&#34;,&#34;&#34;

If,%Parameters%,NotEqual,,Set,&#34;%shortCut_Parameters%&#34;,&#34;#$q#$s#$q-SP&#58;%Parameters%&#34;

...
If variable (%Parameters%) don't exist the name of the variable (%Parameters%) is returned but i want it return ("") nothing
If this can work we have just to add in section [Variables] a line for start program with parameters and nothing else

#18 Nuno Brito

Nuno Brito

    Platinum Member

  • .script developer
  • 10544 posts
  • Location:boot.wim
  • Interests:I'm just a quiet simple person with a very quiet simple life living one day at a time..
  •  
    European Union

Posted 26 July 2007 - 11:08 PM

Yes, a parameters variable seems essential - good idea.

Have you done any more testings with VistaPE? :yahoo:

#19 pedrole15

pedrole15

    Silver Member

  • .script developer
  • 731 posts
  •  
    France

Posted 27 July 2007 - 06:34 AM

Yes, a parameters variable seems essential - good idea.

:yahoo: Ok,it's working like this
[AddShortcut]echo,""echo,"API - Creating a new shortcut for %programTitle%.. [%programFolder%\%programExe%]"If,#1,Equal,,Set,"%shortcut_type%","DE"If,#1,Equal,Desktop,Set,"%shortcut_type%","DE"If,#1,Equal,StartMenu,Set,"%shortcut_type%","SM"If,#1,Equal,QuickLaunch,Set,"%shortcut_type%","QL"If,#1,Equal,AutoStart,Set,"%shortcut_type%","AU"If,#2,Equal,,StrFormat,filename,%Scriptdir%,#2If,%Parameters%,Equal,,Set,"%shortCut_Parameters%",""If,%Parameters%,NotEqual,,Set,"%shortCut_Parameters%","#$q#$s#$q-SP:%Parameters%"If,%IconFile%,Equal,,Set,"%shortCut_IconFile%",""If,%IconFile%,NotEqual,,Set,"%shortCut_IconFile%","#$q#$s#$q-SF:#$pProgramFiles#$p\%programFolder%\%IconFile%"If,%IconIndex%,Equal,,Set,"%shortCut_IconIndex%",""If,%IconFile%,NotEqual,,Set,"%shortCut_IconIndex%","#$q#$s#$q-SI:0"If,%IconIndex%,NotEqual,,Set,"%shortCut_IconIndex%","#$q#$s#$q-SI:%IconIndex"If,%StartMode%,Equal,,Set,"%shortCut_Show%",""If,%StartMode%,Equal,"Max",Set,"%shortCut_Show%","#$q#$s#$q-SS:SW_SHOWMAXIMIZED"If,%StartMode%,Equal,"Min",Set,"%shortCut_Show%","#$q#$s#$q-SS:SW_SHOWMINIMIZED"If,%StartMode%,Equal,"Hide",Set,"%shortCut_Show%","#$q#$s#$q-SS:SW_Hide"If,%StartMode%,Equal,"Normal",Set,"%shortCut_Show%","#$q#$s#$q-SS:SW_SHOWNORMAL"If,%shortcut_type%,Equal,"SM",Run,%BuildModelScript%,Add-Shortcut,"%shortcut_type%\#2","#$pProgramFiles#$p\%programFolder%\%programExe%","%ProgramTitle%","-SW:#$pProgramFiles#$p\%programFolder%%shortCut_IconFile%%shortCut_IconIndex%%shortCut_Parameters%%shortCut_Show%"If,%shortcut_type%,NotEqual,"SM",Run,%BuildModelScript%,Add-Shortcut,"%shortcut_type%","#$pProgramFiles#$p\%programFolder%\%programExe%","%ProgramTitle%","-SW:#$pProgramFiles#$p\%programFolder%%shortCut_IconFile%%shortCut_IconIndex%%shortCut_Parameters%%shortCut_Show%"
In script.project add this:
[variables]%ProgramTitle%=IrfanView%ProgramEXE%=i_view32.exe%ProgramFolder%=IrfanView%IconFile%=Pmagic.ico            ==> Change the default icon of the program by "Pmagic.ico"%Parameters%=i_view32.bmp        ==> Load "i_view.bmp" when start the program[process]Add_Shortcut,DesktopAdd_Shortcut,StartMenuunpackassociate_file,icoassociate_file,bmp

Have you done any more testings with VistaPE? :)

:) Not yet

#20 Nuno Brito

Nuno Brito

    Platinum Member

  • .script developer
  • 10544 posts
  • Location:boot.wim
  • Interests:I'm just a quiet simple person with a very quiet simple life living one day at a time..
  •  
    European Union

Posted 27 July 2007 - 10:29 AM

Won't these functions slug the whole processing? :yahoo:

I've done a small test with a tugzip script last night where I ran the file association for all supported file formats (almost 10 filetypes) and it took 4 minutes from the whole project (which took 5 minutes to be complete - wich )

This would be a severe limitation when building bigger sized projects as it would quickly rise for half an hour to complete a medium packed boot disk.

Also reminding that too many options will surely make things break with other projects and become too specific to buildmodel and liveXP.

I think that parameters and icon index could be used - but having options to max/min/hide/normal would probably be better left out or replaced by batch files don't you think? :)

-------------------------

Or maybe another idea - we check if %startmode% has a value different from empty and if it isn't empty then we process other sections meant to properly handle this and subdivide all these "heavier" tasks on need to use basis.

This could also be applied to similar optional settings (ideal would really keep needed variables as least as possible = 3 ) and instead of slugging everytime we wanted to run a shortcut function. This would only have some speed impact when processing scripts who effectively needed to use these options - will test to see if this improves script performance..

If we have 50 scripts and only 3 use parameters then it wouldn't be good to see all other 47 need to process start mode, icon index and icon file. On my machine, finishing a "normal" project passed from 3 minutes to 14 minutes.. :)

Nice ideas, let's work on them!

:)

#21 Nuno Brito

Nuno Brito

    Platinum Member

  • .script developer
  • 10544 posts
  • Location:boot.wim
  • Interests:I'm just a quiet simple person with a very quiet simple life living one day at a time..
  •  
    European Union

Posted 28 July 2007 - 05:50 PM

Pedrole15, you were right about restricting folders to only start menu - just tried creating an autorun shortcut and it would add the folder instead of an icon.. :)


Added your code snippet.. :yahoo:

#22 Nuno Brito

Nuno Brito

    Platinum Member

  • .script developer
  • 10544 posts
  • Location:boot.wim
  • Interests:I'm just a quiet simple person with a very quiet simple life living one day at a time..
  •  
    European Union

Posted 28 July 2007 - 07:10 PM

Added a new option to the unpack function from API to solve the matter of including subfolders and also allow running a sort of configuration tool whenever needed.

On this case it's used to launch a self extracting 7zip archive

[codebox] [depack] echo,"API - Unpacking files and settings.." Set,%folder_name%,#1 If,%folder_name%,Equal,,Set,%folder_name%,Folder system,refreshvars IniRead,"%ProjectInfo%","TargetPaths","Program_Files",%WorkDir% DirMake,"%targetDir%\%workDir%" DirMake,"%targetDir%\%workDir%\%ProgramFolder%" echo,"Extracting %ProgramTitle%.." ExtractAllFiles,"%ScriptFile%","%folder_name%","%targetDir%\%workDir%\%ProgramFolder%" If,#2,NotEqual,,Run,%api%,special_run,#2,#3 [special_run] ShellExecute,open,"%targetDir%\%workDir%\%ProgramFolder%\#1","#2",%targetDir%\%workDir%\%ProgramFolder% FileDelete,"%targetDir%\%workDir%\%ProgramFolder%\#1" [/codebox] And it can be called from scripts like this example: [code]&#91;process&#93; unpack,folder,asquared_free.exe,&#34;-y&#34; Add_Shortcut,StartMenu[/code]

asquared_free.exe is a big sized application (>15-mb) so we get better results using 7zip compression and also include several subfolders. (good workaround until wb can support subfolders on encoded files)

After this program is launched it will be deleted to clean any traces of it.

Hope you like it - I find it very usefull to extract a lot of files much quickier and also because it was a bit more dificult to define the location of %programfiles% under nativeEx due to the dynamic regional settings.

I think this way we ensure a solid and quick subfolder structure inside wb encoded files for the time being.

:yahoo:

#23 pedrole15

pedrole15

    Silver Member

  • .script developer
  • 731 posts
  •  
    France

Posted 29 July 2007 - 12:28 PM

Nuno,
I have correct some bug in api.script all is working now :yahoo: :)
I have optimized the code for speed i win a half of speed :)

See difference with "associate_file,html" and "associate_file,html,open" the icon is different

Hope you like ?
Attached File  api.script   6.28KB   437 downloads
Attached File  script.project.txt   121.96KB   873 downloads

#24 pedrole15

pedrole15

    Silver Member

  • .script developer
  • 731 posts
  •  
    France

Posted 29 July 2007 - 03:53 PM

For vista something like this must work
[codebox][AddShortcut_Vista] echo,"API - Creating a new shortcut for %programTitle%.. [%programFolder%\%programExe%]" SET,"%My_Shortcut_FOLDER%","Programs\%programFolder%" // <---- %DestDir% If,%pCheckBox1%,Equal,"True",SET,"%My_Shortcut_FOLDER%","Program#$sFiles\%programFolder%" Set,"%shortcut_StartFolder%","#2" // <---- %ParentItem% System,RefreshVars Run,%api%,AddShortcut_#1 If,%shortcut_type%,Equal,"SM",TXTAddLine,%ES%,"!CD\%My_Shortcut_FOLDER%\%programExe%#$c%shortcut_StartFolder%\%ProgramTitle%.lnk,!CD\%My_Shortcut_FOLDER%,%Parameters%,,%IconFile%,/%StartMode%","Append" If,%shortcut_type%,NotEqual,"SM",TXTAddLine,%ES%,"!CD\%My_Shortcut_FOLDER%\%programExe%#$c!DS%shortcut_StartFolder%\%ProgramTitle%.lnk,!CD\%My_Shortcut_FOLDER%,%Parameters%,,%IconFile%,/%StartMode%","Append" [AddShortcut_] Set,"%shortcut_type%","DE" [AddShortcut_Desktop] Set,"%shortcut_type%","DE" [AddShortcut_StartMenu] Set,"%shortcut_type%","SM" If,%shortcut_StartFolder%,Equal,,StrFormat,filename,%Scriptdir%,%shortcut_StartFolder% //[AddShortcut_QuickLaunch] // <---- Don&#39;t know the command for this //Set,"%shortcut_type%","QL" //[AddShortcut_AutoStart] // <---- Don&#39;t know the command for this //Set,"%shortcut_type%","AU" [/codebox] and add in script.project [code]%Parameters%= %IconFile%= %StartMode%=[/code]

If someone know the parameters ? :yahoo:

#25 Nuno Brito

Nuno Brito

    Platinum Member

  • .script developer
  • 10544 posts
  • Location:boot.wim
  • Interests:I'm just a quiet simple person with a very quiet simple life living one day at a time..
  •  
    European Union

Posted 29 July 2007 - 04:30 PM

Hi pedrole15, excellent work!

The proposed api.script file at this moment is only meant to be placed inside a LiveXP, NativeEx, NativePE, etc.. project

For VistaPE and any other project we should create an api.script that will be adapted to support the exact same commands in a way that is compatible with project itself.


AddShortcut_Vista --> should be AddShortcut under VistaPE so that scripts will be "blind" to the specific project details and work in universal way.

For example:

Under LiveXP require_file will copy&expand from the source onto I386\System32 folder, but on vistaPE it should do the same action targeted to Windows\System32

So we don't need to create a require_file_vista, just use an api.script for VistaPE that has the needed values.. :yahoo:

This way scripts are generic and only api.script/script.project needs to be project specific.. :)



If a feature is not supported then it should be omitted/ignored inside the project's api.script - this is one of the reasons why we should be careful and avoid options that are simply too specific and only apply to a sort of projects.


--------------------------

Your code to handle possible shortcut types is very efficient:

Run,%api%,AddShortcut_#1


:)


Will try to test it later today! :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users