views:

461

answers:

6

I have a directory of files that I would like to scan on a regular basis and execute with the default application they are associated with. They are not executable so system("file.torrent"); does not work. How are you able to run files with there associated applications in Perl?

+6  A: 

start

You could manually parse the relevant part of the registry, find the associated application, and kick it off yourself: but the command prompt's built-in start command life easier.

So, for your example you would simply do a system("cmd /c start file.torrent")

If the registry would now the associated app, he just could use the system() method for firing it up.
BeowulfOF
+7  A: 

The standard windows way is with ShellExecute.

In perl you can do it with, well, ShellExecute. Its in the Win32::GUI package.

Have not tried it. But it looks simple enough.

Igal Serban
+2  A: 

Not Perl specific but you can always use the 'start' command. The first argument will be the title of the new command prompt opened and the second argument is the file to open.

system('start "dummy title" "some file.doc"'); # opens the document in word
Brett
+1  A: 

Another option we use is

system("RunDLL32.exe SHELL32.DLL,ShellExec_RunDLL file.torrent")

splintor
A: 

Never use system() on windows ! Crappy and bad method (PAS)

A: 

Hi to all

I wanted to open one file in the local machine if the time is e.g.: 03:00'o clock file has to open other wise the program has to wait until 3:00'o clock how do i create in the perl. I have done this one in this way: ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); if($hour=="3") { $filename="D:\Umesh\13_1_2010.html"; print ("\nThe time is 10'o Clock"); system("start $filename");

} else { print ("\nThe time is not 3'o clock"); } It will open but if i put this exe in startup it will check on that time only program will execute and stoped how can i do this please help..

Umesh
This is not an answer. If you have a question, ask your own: http://stackoverflow.com/questions/ask
ephemient