views:

61

answers:

3

I'm trying to "hide" some of my perl program from the end user to make things easier on them. I'm doing what I can to keep them out of the command prompt. The program itself has a GUI designed in Perl/Tk, so they don't have to worry about the command prompt.

Could I write out a quick batch file that goes along the lines of:

START perl 'C:\[some path here]\myscript.pl'

with START to start a program, the perl interpretor as my program, and the path/name of my perl script as the parameter?

Would I have to specify where to find perl or would Windows just know because perl is in the computer's PATH variable?

Thanks for the help!

+2  A: 

you don't need "start" for this. either add perl.exe from your path or specify the full path to the perl interpreter.

so ... put this in your batch file:

c:\program files\perl.exe "c:\whatever\myscript.perl"

-don

Don Dickinson
+2  A: 

If the idea is to keep them away from the command line, why use a batch file at all? Why not just make a shortcut? (You could use Win32::Shortcut if you don't want to make one by hand.)

cjm
+5  A: 

I have a totally evil VBS script and batch file to deal with this kind of thing with Strawberry Perl Portable. The VBS script runs the batch file without spawning a cmd window. The batch file works out where it is, where perl.exe is relative to it, and runs the perl script. In this case it's to run a Catalyst server, but can be used for anything else too.

Here's the vbs (shudder):

Set fso = CreateObject("Scripting.FileSystemObject")
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run chr(34) &  fso.GetParentFolderName(wscript.ScriptFullName) & "\perlshell.bat"& Chr(34), 0
Set WshShell = Nothing

And here's the batch script (only slightly less shudder):

echo off
set bindir=%~dp0
set perlpath=%bindir%perl\bin
set buildpath=%bindir%\bin
set PATH=%PATH%;%perlpath%;%buildpath%
"%perlpath%\wperl.exe" "%bindir%MyPhp\script\myphp_server.pl" -p 35900
singingfish