Warning: krsort() expects parameter 1 to be array, null given in /home/.fluke/nuno_brito/boot-land.net/forums/sources/d22mods/mvtt.php on line 58

Warning: reset() [function.reset]: Passed variable is not an array or object in /home/.fluke/nuno_brito/boot-land.net/forums/sources/d22mods/mvtt.php on line 59
App scripts - Boot Land
 
> App scripts, Common script templates to work across different projects
Nuno Brito
post Jul 25 2007, 03:45 PM
Post #1


Advanced Member
***

Group: .script developer
Posts: 4,259
Joined: 13-July 06
From: Azores
Member No.: 1


Portugal


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? huh.gif


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:

CODE

[variables]
%api%=%projectdir%\Basic\Build\api.script
Add_Shortcut=Run,%api%,AddShortcut
Require_File=run,%api%,expand_file
Unpack=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_hiveload
hive_unload=run,%api%,reg_hiveunload
reg_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.

CODE

[main]
Title=api
Description=This script contains a set of magic functions that you can use inside your script to make some tasks easier like creating shortcuts and extracting files.
Selected=none
Level=1
Credits=To the whole community of developers, beta testers and active members which make these developments fun and interesting.
Date=2007-JUL-25
Version=2
Contact=http://www.boot-land.net/forums/Common-API-for-projects-t2100.html
Download_Level=0
Author=Boot Land Community



[expand_file]
If,NotExistFile,%target_sys%\#1,CopyOrExpand,"%source_sys%\#1","%target_sys%"




[AddShortcut]
echo,""
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%,#2
Run,%BuildModelScript%,Add-Shortcut,"%shortcut_type%\#2","#$pProgramFiles#$p\%programFolder%\%programExe%","%ProgramTitle%","-SW:#$pProgramFiles#$p\%programFolder%"






[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%"





[reg_hiveload]
/echo,"Loading #1 hive.."
Set,"%hive_file%","%HIVE_#1%"
System,RefreshVars
echo,"Loading hive from %hive_file%"
RegHiveLoad,%reg_temp%,%hive_file%

[reg_hiveunload]
/echo,"Unloading %reg_temp%"
RegHiveUnLoad,%reg_temp%





[do_associate]
echo,""
echo,"API - Associating #1 filetype.."
Set,"%my_file_type_label%","#1file"
Set,"%my_file_type%","#1"
Set,"%my_file_type_action%","#2"
Set,"%my_icon_file%","#3"
Set,"%my_icon_file_number%","#4"

system,refreshvars

hive_load,HKU
reg_add,0x1,"%reg%\Classes\.%my_file_type%",,"%my_file_type_label%"

If,%my_file_type_action%,Equal,,run,%api%,do_associate_action,open
If,%my_file_type_action%,Equal,open,run,%api%,do_associate_with_other_file
If,%my_file_type_action%,Equal,edit,run,%api%,do_associate_action,edit
If,%my_file_type_action%,Equal,icon,run,%api%,do_associate_icon

hive_unload,HKU




[do_associate_action]
If,#1,Equal,open,run,%api%,do_associate_icon
If,%my_file_type_action%,Equal,,Set,"%my_file_type_action%","open"
Set,"%my_parameters%","#$q%1#$q"
If,#2,NotEqual,,Set,"%my_parameters%","#2"
reg_add,0x2,"%reg%\Classes\%my_file_type_label%\shell\%my_file_type_action%\command",,"#$q#$pProgramFiles#$p\%programFolder%\%programExe%#$q#$s%my_parameters%"




[do_associate_with_other_file]
run,%api%,do_associate_icon
Set,%my_parameters%,"#$s#$q%1#$q"
If,%my_icon_file_number%,NotEqual,,Set,%my_parameters%,"#$s%my_icon_file_number%"
system,refreshvars
reg_add,0x2,"%reg%\Classes\%my_file_type_label%\shell\%my_file_type_action%\command",,"%my_icon_file%%my_parameters%"



[do_associate_icon]
If,%my_icon_file%,Equal,,Set,"%my_icon_file%","#$q#$pProgramFiles#$p\%programFolder%\%programExe%#$q"
system,refreshvars
If,%my_icon_file_number%,Equal,,reg_add,0x2,"%reg%\Classes\%my_file_type_label%\DefaultIcon",,"%my_icon_file%"
If,%my_icon_file_number%,NotEqual,,reg_add,0x2,"%reg%\Classes\%my_file_type_label%\DefaultIcon",,"%my_icon_file%#$c%my_icon_file_number%"



[demo usage]
; Use these examples to see how these commands can be applied inside your app scripts

Add_Shortcut
Add_Shortcut,StartMenu
Add_Shortcut,StartMenu,Games
Add_Shortcut,QuickLaunch
Add_Shortcut,AutoStart
Add_Shortcut,Desktop

require_file,myLibrary.dll

unpack
unpack,AnotherFolder

hive_load,HKU
hive_unload,HKU

reg_add,0x1,"%reg%\Classes\filetype","test","1"

associate_file,html
associate_file,html,open,c:\test.exe
associate_file,html,open,c:\test.exe,/run=%2
associate_file,html,edit
associate_file,html,icon,c:\test.exe
associate_file,html,icon,%systemroot%\System32\Shell32.dll,-153



[history]
070513 - api.script was created.
070718 - added function "require" (extract/check if system files are available and expand from source if needed
- added syntax guide inside script.project from livexp
- added %HKLM% and %HKCU% to write registry keys
- added %source_win%, %target_win%, %source_sys%, %target_sys%
that allow access work folders under most situations (supports both Install CD files or Installed windows dirs)
070723 - added support for creating start menu items based on the folder where the script is placed
070723 - hive_load and hive_unload commands added to support HKCU,HKU and HKLM
070723 - reg_add command added with support for internal and external hive registry writes
070723 - association command was also added to bring support to file associations
070724 - added support to add association to any other files along with custom parameters and custom icons (like shell32.dll,-153)
070724 - unpack was made simpler also extracting from any folder when specified



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

CODE
[demo usage]
; Use these examples to see how these commands can be applied inside your app scripts

Add_Shortcut
Add_Shortcut,StartMenu
Add_Shortcut,StartMenu,Games
Add_Shortcut,QuickLaunch
Add_Shortcut,AutoStart
Add_Shortcut,Desktop

require_file,myLibrary.dll

unpack
unpack,AnotherFolder

hive_load,HKU
hive_unload,HKU

reg_add,0x1,"%reg%\Classes\filetype","test","1"

associate_file,html
associate_file,html,open,c:\test.exe
associate_file,html,open,c:\test.exe,/run=%2
associate_file,html,edit
associate_file,html,icon,c:\test.exe
associate_file,html,icon,%systemroot%\System32\Shell32.dll,-153



These might seem a bit strange and very few when you first look on them, but rest assured that they truly allow to replace most "older" coding which made your scripts limited to work under a specific project.


To see how this works in real life usage, let's look on driveimageXML script as example before and after applying the new method.

Before

CODE

[Process]
Echo,"Making new directories.."
IniRead,"%ProjectInfo%","TargetStrings","sProgram_Files",%WorkDir%
DirMake,%targetDir%\%workDir%\dixml
// Add shortcuts
If,%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\software
Echo,"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

CODE

[variables]
%ProgramTitle%=DriveImage XML
%ProgramEXE%=dixml.exe
%ProgramFolder%=DriveImageXML

[process]
If,%pCheckBox1%,Equal,True,Add_Shortcut,Desktop
Add_Shortcut,StartMenu
unpack
echo,"Expanding DLLs..."
require_file,APPHELP.DLL
require_file,LZ32.DLL
require_file,WOW32.DLL
require_file,NTVDM.EXE
hive_load,HKU
reg_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 examples

SmartFTP

CODE

[variables]
%ProgramTitle%=SmartFTP
%ProgramEXE%=SmartFTP.exe
%ProgramFolder%=SmartFTP

[process]
Add_Shortcut,StartMenu
unpack
require_file,APPHELP.DLL
require_file,ATL.DLL
require_file,CLBCATQ.DLL
require_file,COMRES.DLL
require_file,CREDUI.DLL
require_file,CRYPT32.DLL
require_file,CSCDLL.DLL
require_file,CSCUI.DLL
require_file,HNETCFG.DLL
require_file,IMGUTIL.DLL
require_file,IPHLPAPI.DLL
require_file,MFC42.DLL
require_file,MLANG.DLL
require_file,MSASN1.DLL
require_file,MSHTML.DLL
require_file,MSIMTF.DLL
require_file,MSLS31.DLL
require_file,MSV1_0.DLL
require_file,MSWSOCK.DLL
require_file,MSXML3.DLL
require_file,NETSHELL.DLL
require_file,OLEACC.DLL
require_file,PNGFILT.DLL
require_file,RASADHLP.DLL
require_file,RASAPI32.DLL
require_file,RASMAN.DLL
require_file,RICHED20.DLL
require_file,RICHED32.DLL
require_file,RSAENH.DLL
require_file,RTUTILS.DLL
require_file,SHDOCVW.DLL
require_file,WSHTCPIP.DLL




Reg Shot

CODE

[variables]
%ProgramTitle%=RegShot
%ProgramEXE%=RegShot.exe
%ProgramFolder%=RegShot

[process]
Add_Shortcut,StartMenu
unpack



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.

smile.gif


--------------------
Use the search tool to find all posts made by other members and help you solve any doubts quickly by yourself.
Whenever possible - place your questions including as many details as you can to help us help you - Thanks!

nuno? --> pics
Go to the top of the page
 
+Quote Post
Digg this topic Add to my del.icio.us 16 Pages V   1 2 3 > »   
Start new topic
Replies (1 - 9)
pedrole15
post Jul 25 2007, 10:24 PM
Post #2


Advanced Member
***

Group: .script developer
Posts: 226
Joined: 18-August 06
Member No.: 183


France


QUOTE (Nuno Brito @ Jul 25 2007, 03:45 PM) *

Nuno i think you must correct this :

CODE
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%,#2
Run,%BuildModelScript%,Add-Shortcut,"%shortcut_type%\#2","#$pProgramFiles#$p\%programFolder%\%programExe%","%ProgramTitle%","-SW:#$pProgramFiles#$p\%programFolder%"


by

CODE
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%,#2
If,%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


--------------------
Make your script quickly with MakeScript
New Api version 6 for LiveXP and VistaPE
Go to the top of the page
 
+Quote Post
Nuno Brito
post Jul 25 2007, 10:44 PM
Post #3


Advanced Member
***

Group: .script developer
Posts: 4,259
Joined: 13-July 06
From: Azores
Member No.: 1


Portugal


Hi Pedrole15!

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

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)

CODE

[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%,#2

Set,"%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,RefreshVars

Run,%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.. smile.gif

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.. cheers.gif

CODE

[variables]
%ProgramTitle%=Hearts
%ProgramEXE%=MSHEARTS.EXE
%ProgramFolder%=MS_Hearts

[process]
Echo,"Create a shortcut.."
Add_Shortcut,StartMenu,,MSHEARTS.EXE
require_file,mshearts.exe
require_file,mshearts.hlp
require_file,mshearts.cnt
require_file,SHIMENG.DLL
require_file,ACGENRAL.DLL
require_file,CARDS.DLL
require_file,SHIMENG.DLL
require_file,HHCTRL.OCX
require_file,MFC42U.DLL


--------------------
Use the search tool to find all posts made by other members and help you solve any doubts quickly by yourself.
Whenever possible - place your questions including as many details as you can to help us help you - Thanks!

nuno? --> pics
Go to the top of the page
 
+Quote Post
pedrole15
post Jul 25 2007, 11:04 PM
Post #4


Advanced Member
***

Group: .script developer
Posts: 226
Joined: 18-August 06
Member No.: 183


France


QUOTE (Nuno Brito @ Jul 25 2007, 10:44 PM) *

I'am trying some tweak
CODE
[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%,#2
If,#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
CODE

[variables]
%ProgramTitle%=IrfanView
%ProgramEXE%=i_view32.exe
%ProgramFolder%=IrfanView
%IconFile%=Pmagic.ico
%Parameters%=i_view32.bmp

[process]
Add_Shortcut,Desktop,,%Parameters%,%IconFile%,Max
Add_Shortcut,StartMenu
unpack

associate_file,ico
associate_file,bmp

It 's working well and can be use with VistaPE with same syntax


--------------------
Make your script quickly with MakeScript
New Api version 6 for LiveXP and VistaPE
Go to the top of the page
 
+Quote Post
Nuno Brito
post Jul 25 2007, 11:43 PM
Post #5


Advanced Member
***

Group: .script developer
Posts: 4,259
Joined: 13-July 06
From: Azores
Member No.: 1


Portugal


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


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.. smile.gif



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. cheers.gif


--------------------
Use the search tool to find all posts made by other members and help you solve any doubts quickly by yourself.
Whenever possible - place your questions including as many details as you can to help us help you - Thanks!

nuno? --> pics
Go to the top of the page
 
+Quote Post
psc
post Jul 26 2007, 07:50 AM
Post #6


Guru
***

Group: .script developer
Posts: 3,130
Joined: 14-July 06
From: Korschenbroich, Germany
Member No.: 3


Germany


QUOTE (Nuno Brito @ Jul 26 2007, 01:43 AM) *
hmm.. good approach, are you available to start porting these api functions to vistape? thumbup.gif


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.. smile.gif



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. cheers.gif

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


--------------------
Build the house starting with the the basement rather than with the roof! But always have in mind how the roof should be made!

There are very rarely problems, in most cases there are issues.

There are never stupid questions, there can be only stupid answers
Go to the top of the page
 
+Quote Post
Nuno Brito
post Jul 26 2007, 09:21 AM
Post #7


Advanced Member
***

Group: .script developer
Posts: 4,259
Joined: 13-July 06
From: Azores
Member No.: 1


Portugal


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

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


Will look back on the buildmodel documentation and see how it can be implemented.. smile.gif


--------------------
Use the search tool to find all posts made by other members and help you solve any doubts quickly by yourself.
Whenever possible - place your questions including as many details as you can to help us help you - Thanks!

nuno? --> pics
Go to the top of the page
 
+Quote Post
psc
post Jul 26 2007, 06:11 PM
Post #8


Guru
***

Group: .script developer
Posts: 3,130
Joined: 14-July 06
From: Korschenbroich, Germany
Member No.: 3


Germany


QUOTE (Nuno Brito @ Jul 26 2007, 11:21 AM) *
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.. smile.gif

I do not want to prohibit you to look into the doc (it is really explained there thumbsup.gif ).
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


--------------------
Build the house starting with the the basement rather than with the roof! But always have in mind how the roof should be made!

There are very rarely problems, in most cases there are issues.

There are never stupid questions, there can be only stupid answers
Go to the top of the page
 
+Quote Post
psc
post Jul 26 2007, 06:17 PM
Post #9


Guru
***

Group: .script developer
Posts: 3,130
Joined: 14-July 06
From: Korschenbroich, Germany
Member No.: 3


Germany


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' hypocrite.gif)

Peter


--------------------
Build the house starting with the the basement rather than with the roof! But always have in mind how the roof should be made!

There are very rarely problems, in most cases there are issues.

There are never stupid questions, there can be only stupid answers
Go to the top of the page
 
+Quote Post
Nuno Brito
post Jul 26 2007, 07:01 PM
Post #10


Advanced Member
***

Group: .script developer
Posts: 4,259
Joined: 13-July 06
From: Azores
Member No.: 1


Portugal


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... laugh.gif (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.. smile.gif


--------------------
Use the search tool to find all posts made by other members and help you solve any doubts quickly by yourself.
Whenever possible - place your questions including as many details as you can to help us help you - Thanks!

nuno? --> pics
Go to the top of the page
 
+Quote Post

16 Pages V   1 2 3 > » 
Reply to this topicStart new topic

Members Who Viewed Topic Today ()

 

RSS Lo-Fi Version Time is now: 24th October 2007 - 05:16 PM

MKPortal ©2003-2006 mkportal.it