Wanted: pkg to read/write windows .lnk/.pif files 
Author Message
 Wanted: pkg to read/write windows .lnk/.pif files

I've been thinking of writing an export/import tool for a
windows (win98) start menu tree.  I want to save my start
menu, do a complete reinstall of windows and all the stuff
I've installed (most probably re-arranging the drives and
installation directories -- ie. don't put everything into
"c:/program files/"), and import the start menu and have the
tool fix the .lnk and .pif files to reflect the new locations
of everything.

What I need, tho, is a way to read and write the .lnk and .pif
files.  So, is there a package for Tcl that would do this?  ...A
utility that Tcl can use?

I've successfully managed to avoid windows for many, many years
so I may not even know what I'm talking about.  I don't see
any windows utilities that allow one to create the .lnk/.pif
files in batch mode -- I've created/customized the start menu
by an extremely tedious point and click process.  There must
be a way tho -- after all when I run the setup.exe's, the
appropriate .lnk and .pif files are created.  Do I need to
write a custom program to do this?

Thanks.

Dave Bodenstab



Mon, 03 Jul 2006 01:20:45 GMT  
 Wanted: pkg to read/write windows .lnk/.pif files

Quote:

> I've been thinking of writing an export/import tool for a
> windows (win98) start menu tree.  I want to save my start
> menu, do a complete reinstall of windows and all the stuff
> I've installed (most probably re-arranging the drives and
> installation directories -- ie. don't put everything into
> "c:/program files/"), and import the start menu and have the
> tool fix the .lnk and .pif files to reflect the new locations
> of everything.

> What I need, tho, is a way to read and write the .lnk and .pif
> files.  So, is there a package for Tcl that would do this?  ...A
> utility that Tcl can use?

> I've successfully managed to avoid windows for many, many years
> so I may not even know what I'm talking about.  I don't see
> any windows utilities that allow one to create the .lnk/.pif
> files in batch mode -- I've created/customized the start menu
> by an extremely tedious point and click process.  There must
> be a way tho -- after all when I run the setup.exe's, the
> appropriate .lnk and .pif files are created.  Do I need to
> write a custom program to do this?

You can do everything you mention except the PIF files using freeWrap (see
http://freewrap.sourceforge.net/). FreeWrap includes some Windows-specific
features you will find useful. FreeWrap also allows you to produce a
single-file executable program out of your TCL script.


Mon, 03 Jul 2006 10:46:02 GMT  
 Wanted: pkg to read/write windows .lnk/.pif files

Quote:
> I've been thinking of writing an export/import tool for a
> windows (win98) start menu tree.  I want to save my start
> menu, do a complete reinstall of windows and all the stuff
> I've installed (most probably re-arranging the drives and
> installation directories -- ie. don't put everything into
> "c:/program files/"), and import the start menu and have the
> tool fix the .lnk and .pif files to reflect the new locations
> of everything.

> What I need, tho, is a way to read and write the .lnk and .pif
> files.  So, is there a package for Tcl that would do this?  ...A
> utility that Tcl can use?

> I've successfully managed to avoid windows for many, many years
> so I may not even know what I'm talking about.  I don't see
> any windows utilities that allow one to create the .lnk/.pif
> files in batch mode -- I've created/customized the start menu
> by an extremely tedious point and click process.  There must
> be a way tho -- after all when I run the setup.exe's, the
> appropriate .lnk and .pif files are created.  Do I need to
> write a custom program to do this?

There's nothing special about .lnk files. They are just regular text files
easily created with [open c:/my/file.lnk w] then [puts $mylinkinformation].
I'm not sure about .pif files, but I'd wager they are the same (are they
even necessary anymore?).

Fire up Notepad and open any .lnk file and you will see what kind of info
you need to write to the file and what format it's in.

I do a lot of scripting like this at work, but I use Linux at home so
forgive the lack of detail here. I don't have .lnk/.pif files in front of
me. If you're versed in M$'s scripting language, you can create an instance
of the WSH Shell, and there is a method to create .lnk files. But that's
just making it more complicated than it needs to be.



Mon, 03 Jul 2006 12:36:07 GMT  
 Wanted: pkg to read/write windows .lnk/.pif files

Quote:

> But that's
> just making it more complicated than it needs to be.

Until MS changes the format of link files in some release, and your code
no longer works. :-)  There's a good reason to go thru the defined APIs,
but as always the effort is a trade-off you have to consider.

--
Darren New, San Diego CA USA (PST)
   Many are cold, but few are frozen.



Tue, 04 Jul 2006 00:12:16 GMT  
 Wanted: pkg to read/write windows .lnk/.pif files

Quote:

>> But that's
>> just making it more complicated than it needs to be.

> Until MS changes the format of link files in some release, and your code
> no longer works. :-)  There's a good reason to go thru the defined APIs,

...because we know MS would never change those.  :D

--
| Don Porter          Mathematical and Computational Sciences Division |

| http://math.nist.gov/~DPorter/                                  NIST |
|______________________________________________________________________|



Tue, 04 Jul 2006 00:37:00 GMT  
 Wanted: pkg to read/write windows .lnk/.pif files
Thanks for the hints.

I did not see anything obvious with FreeWrap that addressed
creating .lnk files...

I have found C code snippets that create the .lnk files; cygwin
also creates them with its 'ln -s', but Tcl's "file link"
command fails (btw, this is win98se).

The .pif files are necessary for some legacy DOS programs.

Both the .lnk and .pif are binary files; I found a site containing
the OS-specific formats for the .pif files.

I found references to something called wscript/wsh but I could
not seem to find a "language reference manual" for them, and the
examples shown seem to require an in depth knowledge of something
called an "object model".

I'm beginning to think that this is beyond being a fairly simple
project; I was hoping that there would be an existing tool that
I could interface with Tcl that would create these magic files.
The wscript/wsh reference seems worth pursuing.  Anyone know of
any howto's?

Dave Bodenstab



Tue, 04 Jul 2006 02:33:45 GMT  
 Wanted: pkg to read/write windows .lnk/.pif files
Hi Dave,

Quote:

> I'm beginning to think that this is beyond being a fairly simple
> project;

Googling for "tcl shortcut extension" turns up a number of Tcl
extensions that do this.  <http://qwerty.maxwell.syr.edu/nt-tcl/> is
the first hit and it looks pretty good.

benny



Tue, 04 Jul 2006 03:59:31 GMT  
 Wanted: pkg to read/write windows .lnk/.pif files
Quote:

> Hi Dave,


> > I'm beginning to think that this is beyond being a fairly simple
> > project;

> Googling for "tcl shortcut extension" turns up a number of Tcl
> extensions that do this.  <http://qwerty.maxwell.syr.edu/nt-tcl/> is
> the first hit and it looks pretty good.

I've used this and it works for me.
Roy
Quote:

> benny



Tue, 04 Jul 2006 04:29:43 GMT  
 Wanted: pkg to read/write windows .lnk/.pif files

Quote:
> Thanks for the hints.

> I did not see anything obvious with FreeWrap that addressed
> creating .lnk files...

> I have found C code snippets that create the .lnk files; cygwin
> also creates them with its 'ln -s', but Tcl's "file link"
> command fails (btw, this is win98se).

> The .pif files are necessary for some legacy DOS programs.

> Both the .lnk and .pif are binary files; I found a site containing
> the OS-specific formats for the .pif files.

> I found references to something called wscript/wsh but I could
> not seem to find a "language reference manual" for them, and the
> examples shown seem to require an in depth knowledge of something
> called an "object model".

Right, COM. This isn't a M$ newsgroup I know, but the "language reference
manual" you need is called MSDN. And the "man page" you're looking for is
here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/scri...

My personal opinions and my love for Tcl aside - If you're going to be using
a lot of the Windows API, creating OS-specific objects, and generally
manipulating Windows, maybe Tcl isn't the way to go. Hint: VB Script. But
this isn't the place to help you with that.



Tue, 04 Jul 2006 06:08:49 GMT  
 Wanted: pkg to read/write windows .lnk/.pif files

Quote:

> Thanks for the hints.

> I did not see anything obvious with FreeWrap that addressed
> creating .lnk files...

Try using the freewrap::shortcut command as documented at
http://freewrap.sourceforge.net/freewrap_howto.html#9


Tue, 04 Jul 2006 07:52:47 GMT  
 Wanted: pkg to read/write windows .lnk/.pif files
Looks like a real can of worms... I'll look into this wsh stuff.
Maybe I can still use Tcl to traverse the start menu and generate
the script to rebuild it.  Thanks for the info.


Tue, 04 Jul 2006 08:07:54 GMT  
 Wanted: pkg to read/write windows .lnk/.pif files

[...]

Quote:
> What I need, tho, is a way to read and write the .lnk and .pif
> files.  So, is there a package for Tcl that would do this?  ...A
> utility that Tcl can use?

[...]

Have you tried tlink ?

http://www.sensus.org/tcl/tlink32.htm
http://www.sensus.org/tcl/tlink11.tgz

--
-eric



Tue, 04 Jul 2006 16:04:41 GMT  
 Wanted: pkg to read/write windows .lnk/.pif files

Quote:
> What I need, tho, is a way to read and write the .lnk and .pif
> files.  So, is there a package for Tcl that would do this?  ...A
> utility that Tcl can use?

Something I didn't realize is that Windows2000 supports hard file
links that are NOT .lnk files.

If you use the [file link name target] command. Tcl actually
creates a hard link, just like your favorite *nix system!

In fact, it works exactly the same...even without the .lnk
extensions.

Ralph



Tue, 04 Jul 2006 22:50:18 GMT  
 
 [ 13 post ] 

 Relevant Pages 

1. Reading .lnk files

2. Help wanted on reading/writing disk and writing your own OS

3. Help wanted on reading/writing disk and writing your own OS

4. Windows .ini file read/write

5. Read/write binary files in Linux and Windows

6. reading/writing files in windows

7. .PIF writing

8. Clarification: read/write slow, and TCPSocket and sys{read,write}

9. read/write slow, and TCPSocket and sys{read,write}

10. Reading from input file writing to output file

11. Q: simple example of read file->convert char(s)->write file needed

12. Reading a binary file / writing binary data to a file

 

 
Powered by phpBB® Forum Software