Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make a shortcut for a Perl program under Windows using a batch file?

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?

like image 501
Micah Avatar asked Jan 19 '26 08:01

Micah


2 Answers

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
like image 146
singingfish Avatar answered Jan 21 '26 02:01

singingfish


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

like image 20
Don Dickinson Avatar answered Jan 21 '26 02:01

Don Dickinson