LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

mklink interface

(Tried posting this to LV Idea Exchange, but keeps erroring out...)

 

Need to create/delete/rename some symbolic (could be hard) links from within LabVIEW.  Either I didn't look hard enough or there isn't currently any interface to mklink. How about adding that capability to the different file functions?

As of now I only need to delete/create symbolic links, but it would be good to have all the capabilities of mklink available.

0 Kudos
Message 1 of 9
(3,841 Views)

Laboratory Virtual Instrument Engineering Workbench.  LabVIEW is for creating Virtual Instruments that would be helpful from an Engineering perspective.  There are plenty of systems that allow a general programmer to access Windows-specific commands (such as mklink) -- this just isn't the purpose of LabVIEW.  Having said that, there is no reason you couldn't build a MkLink VI that does a System Call with parameters and parses the returned String ...

 

Bob Schor

0 Kudos
Message 2 of 9
(3,832 Views)

LabVIEW is for creating Virtual Instruments that would be helpful from an Engineering perspective.


You got to be kidding here no?



There are plenty of systems that allow a general programmer to access Windows-specific commands (such as mklink) -- this just isn't the purpose of LabVIEW.


Good one again. Like maybe mkdir, rmdir, etc? Why does LabVIEW provide an interface to those Windows' specific commands, when there are plenty of systems to allow that? A symbolic link is a file, and LabVIEW allows one to create files directly, no?



Having said that, there is no reason you couldn't build a MkLink VI that does a System Call with parameters and parses the returned String


I know very well how to do that and have already done it. Seems like a good addition to me, be it on Windows, Linux, MacOS, etc.

0 Kudos
Message 3 of 9
(3,821 Views)

Just to add that what I created calls into kernel32.dll, CreateSymbolicLink functions.  Calling mklink directly is a bit silly as it requires the cmd.exe overhead.

0 Kudos
Message 4 of 9
(3,818 Views)

I have a colleague who uses LabVIEW.  He wants to make a Data De-duplication Program in LabVIEW.  I'm surprised he hasn't tried to make a text editor in LabVIEW (it can handle strings, after all ...).

 

"When your only tool is a Hammer, Every Problem looks like a Nail".

 

Bob Schor

0 Kudos
Message 5 of 9
(3,807 Views)

Plonk!  Have a nice day Mr. Zealot.

0 Kudos
Message 6 of 9
(3,794 Views)

It wasn't before Windows 2000 that the NTSF driver actually supported something like hardlinks and took until Windows XP until they added Softlink support. The single API you found only got introduced in Windows 7. Anything else you want to do with soft and hardlinks under Windows such as querying the path such a "reparse point" points to, (official NTFS name for these things) still requires to call directly into the NTFS kernel driver.

And please note that even Windows 10 upgrade will get pretty badly hosed if you redirect system paths or even your home environment C:\Users\<your name> using these techniques yourself. This still doesn't sound to me like reparse points are first class citicens in the Windows environment like other file objects.

 

And while you are correct that calling an external command under Windows is a fairly expensive operation, the first question is always how often you intend to call this function. Unless you can foresee a possibility that a function is called many times in a tight loop, dismissing a solution based on real (and more often perceived) performance reasons is considered highly premature optimization!

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 7 of 9
(3,759 Views)

I understand the limitation of reparse points in different versions of Windows, but I need to create some symbolic links, under program control, in a use case where I will not run under those limitations.

 

In my simple case, it is actually much easier to code a kernel32 DLL call status = CreateSymbolicLinkA (link, target, isDir?) than fork a cmd.exe for mklink and parse the output.

 

Then I wondered couldn't  this be a flag into CreateFile/CreateFolder?  Tried to post under Idea Exchange but the website didn't accept the text I cut & pasted into the forum post.That was all.

 

 

 

0 Kudos
Message 8 of 9
(3,730 Views)

I don't think overloading creat file/directory sounds like a good idea. The only thing in common by both is the desired path. Create file requires a permission, while create link requires the actual path the link should point to.

Overloading these functions would unneccessarily compllicate the node interface with very different parameters which are only neccessary in a specific mode of that function and totally meaningless for the other mode(s).

 

Of course since there is now an API to create a link, it's easiest to call that instead of mklink, but dismissing to call external commands principally is not really useful. Under Unix it is in fact the standard way of extending os funtionality. Instead of creating one application which tries to do everything more or less badly, ypu create little tools which do one thing good and call them all from your application,

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 9 of 9
(3,720 Views)