Links to programs in Windows?

Jim Bufalini jim at visitrieve.com
Thu Feb 4 00:24:29 EST 2010


Kresten,

The quickest way on a PC would be to use the registry because it is in
memory. But, if you are not comfortable with this, you can get a complete
list of all "installed" programs on a PC by walking down the Program Files
directory and all of it subdirectories and looking for .exe files. I don't
think you are going to find what you are looking for where you are looking
because even if it exists, it would contain .lnk files which are shortcuts
themselves.

Here is some code you could use to get a list of all EXE files on XP and
Vista/7. It can take a while (many seconds on a large system) because for
example, in my case there are almost 20,000 directories to search because
you cannot look at just the root directories under Program Files because
programs like Word are in sub-sub-directories. 

You will also probably end up with a much larger list of programs than you
need, so you will probably want to add filters by say having a list of
directories you are interested in and skip entire directory trees if they
are not on your list. But any way, this following code will give you all
programs on a PC. You can modify it with filters to shorten its search. I
didn't use recursion, because you can easily hit the recursion limit.

local sFolderList, sProgramList, sCnt

ON mouseUp pMouseBtnNo
    put 0 into sCnt
    put empty into sFolderList
    put empty into sProgramList
    GetAllExecutables
    REPEAT WHILE line 1 of sProgramList <> "Done"
	  -- Necessary because not using recursion
        wait 0 milliseconds with messages 
    END repeat
    put sProgramList -- Test line can be removed
    delete line 1 of sProgramList
    -- Do any processing of sProgramList here
END mouseUp

ON GetAllExecutables pCurrentFolder
    local tRootFolder, tFileList, tSubFolderList
    ----
    put "C:/Program Files/" into tRootFolder
    IF sFolderList is empty THEN
        SET the defaultfolder to tRootFolder
        put URLDecode(the folders) into sFolderList
        filter sFolderList without ".*"
        -- You can filter other directories out here
        put line 1 of sFolderList into pCurrentFolder
    END if
    IF pCurrentFolder is empty THEN exit GetAllExecutables
    IF char -1 of pCurrentFolder <> "/" THEN put "/" after pCurrentFolder
    SET the defaultfolder to (tRootFolder & pCurrentFolder & "/")
    put the files into tFileList
    filter tFileList with "*.exe"
    filter tFileList without "uninstall*"
    REPEAT FOR each line tFile in tFileList
        put (the defaultFolder & "/" & tfile) into line (the number of lines
in sProgramList +1) of sProgramList
    END repeat
    delete line 1 of sFolderList
    put URLDecode(the folders) into tSubFolderList
    filter tSubFolderList without ".*"
    IF tSubFolderList <> empty THEN
        REPEAT FOR each line tSubfolder in tSubFolderList
            put pCurrentFolder & tSubFolder & "/" & cr before sFolderList
        END repeat
    END if
    IF sFolderList is empty THEN 
        put "Done" & cr before sProgramList
        exit GetAllExecutables
    END if
    put line 1 of sFolderList into pCurrentFolder
    -----
    add 1 to sCnt -- Test line can be removed
    put sCnt -- Test line can be removed
    -----
    send "GetAllExecutables" && pCurrentFolder to me in 0 milliseconds --
use send to not hit recursion limit
END GetAllExecutables

Aloha from Hawaii,

Jim Bufalini




Kresten Bjerg wrote:

> Thank you for the meticulous answer. However, I am  a dilletant and
> cannot see my way through all this.
> 
> We have this process:
> 
>     answer file "select a program" with "/C:/Documents and
> settings/<User>/Start Menu/Programs"
> 
> , and  it is  a function which shall permit novice computer users to
> produce a few buttons inside their personal electronic diary
> 
>  ,permitting them to open the few other programs they will tend to use,
> perhaps word, picasa, mail-program, calculator, checkers...etc
> 
>  simplifying their everyday, and having their use of such programs
> logged (timeindexed) into the diary.
> 
> The paradox is, that in windows, they can open the start menu, go to
> programs, and see all programs there,
> 
> and we can move down  the directories manually, and find all these
> links
> in the Start Menu/Programs  folder.
> 
>  But Revolution cannot find them , just find a very few of them, by
> that
> Answer line.
> 
> 
> 
> I Understand, that the line may have to be changed, in order to fit
> windows 7, - but as long as it doesn't work  even on  Windows XP
> 
>   that seems to be a secondary question.
> 
> Maybe many scriptlines have to be concocted, to produce an acceptable
> result corresponding to what can be done so simply in Mac,
> 
>  calling "Applications".
> 
> So,pragmatically: how would you script to solve the problem.
> 
> That a few programs may escape, is not a serious problem in this
> context.
> 
> Still hopefully
> 
> Kresten
> 
> 
> 
> www.phenomenalog.dk <http://www.phenomenalog.dk/>
> www.phenomenalog.wikispaces.com
> <http://www.phenomenalog.wikispaces.com/>
> 
> 
> 
> -
> 
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution




More information about the use-livecode mailing list