SyMenu Forum

SyMenu

 

HomeConfigure portable programs

How to configure programs in SyMenu

Convert Winpanpack Menu to SyMenu Messages in this topic - RSS

cemax
cemax
Posts: 1


21 days ago
cemax
cemax
Posts: 1
Hi everyone,
I have been using winpenpack for years and I had created a menu with hundreds of programs that I was sorry to miss.
For this purpose I wrote a small script to convert the XML menu structure from Winpanpack Menu to SyMenu.

The original idea would have been to make a "serious" tool that works using XML methods; for reasons of time, however, I abandoned it in favor of a quick & dirty solution that brutally acts as a parser, without too many checks and refinements.
But it seems to work smile

here is the commented script:




'************************************************* **********************************
'* Run CSCRIPT menuconv.vbs
'*
'* Reads winpenpack.xml
'* Writes SyMenuItem.xml
'*
'* At the end from SyMenuItem.xml you have to create SyMenuItem.zip
'* and put it in SyMenu Config
'*
'* In SyMenu Icons there must be an icon called Default.ico
'*
'* NOTE 1: if in the xml input there are <description> multi-line fields
'* must be made single line by removing cr-lf
'* NOTE 2: In line 78, if necessary, adapt the translation of the relative path
'* from $ drive xxx to what you need ( it depends on the structure)
'************************************************* **********************************


Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fso, fin, fout, rigain, rigaout, rigaout1, count, wsh, CCalls, CSec, objArgs, maxrec
Dim filein, fileout
Set fso = CreateObject("Scripting.FileSystemObject")
Set wsh = WScript.CreateObject("WScript.Shell")
Set objArgs = WScript.Arguments


fso.CreateTextFile "SyMenuItem.xml"
Set fin = fso.OpenTextFile("winpenpack.xml", ForReading, False)
Set fout = fso.OpenTextFile("SyMenuItem.xml", ForWriting, False)
CountCont = 0
CountItem = 0


'* HEADER
fout.WriteLine "<?xml version=""1.0"" encoding=""UTF-16""?>"
fout.WriteLine "<SyRoot>"


Do While (fin.AtEndOfStream <> True and rigain <> "<Separator/>")
rigain = trim(fin.ReadLine)
'* find "files name="
'*write SYCONTAINER
i1 = instr(rigain, "files name=")
If i1 > 0 then
if CountCont > 0 then '* if not first
WScript.Echo "</SyContainer>"
fout.WriteLine "</SyContainer>"
WScript.Echo " "
end if
rigaout = mid(rigain, 14, len(rigain)-15)
rigaout1 = "<SyContainer name=""" & rigaout & """ defaultIcon=""10"" description="""">"
WScript.Echo rigaout1
fout.WriteLine rigaout1
CountCont = CountCont + 1
end if


'* finds file name= and takes all attributes
'* writes SyProgramCmd>
i1 = instr(rigain, "file name=")
If i1 > 0 then
'* Name
rigaout = mid(rigain, 13, len(rigain)-14)
WScript.Echo "<SyProgramCmd>"
fout.WriteLine "<SyProgramCmd>"
rigaout1 = "<name>" & rigaout & "</name>"
WScript.Echo rigaout1
fout.WriteLine rigaout1
'* writes a line Default.ico
fout.WriteLine "<icon>.\Icons\Default.ico</icon>"
rigain = trim(fin.ReadLine)
rigain = trim(fin.ReadLine)
'* Description
if left(rigain, 4) = "<des" then
rigaout = mid(rigain, 14, len(rigain)-27)
rigaout1 = "<description>" & rigaout & "</description>"
WScript.Echo rigaout1
fout.WriteLine rigaout1
rigain = trim(fin.ReadLine)
end if
'* Path
rigaout = mid(rigain, 7, len(rigain)-13)
'* Substitutes relative path $Drive\ with ..\ (ok if symenu and other sw on same folder level)
rigaout = replace (rigaout, "$Drive\Uti", "..")
rigaout1 = "<path>" & rigaout & "</path>"
WScript.Echo rigaout1
fout.WriteLine rigaout1
WScript.Echo "</SyProgramCmd>"
fout.WriteLine "</SyProgramCmd>"
CountItem = CountItem + 1
end if

loop


'* tail
WScript.Echo "</SyContainer>"
WScript.Echo "</SyRoot>"
fout.WriteLine "</SyContainer>"
fout.WriteLine "</SyRoot>"


WScript.Echo " * * * * * * * * * * * * * * * * * * "


WScript.Echo CountCont & " Written categories"
WScript.Echo CountItem & " Written Items"
fin.Close
fout.Close
link
Gianluca
Gianluca
Administrator
Posts: 871


21 days ago
Gianluca
Gianluca
Administrator
Posts: 871
Thanks cemax.
Now let's see if some winPenPack user need to convert their old menu to SyMenu.
link



UGM.NET ©2002-2019
By Gianluca Negrelli - Contact me