@rem = '--*-Perl-*-- @echo off if "%OS%" == "Windows_NT" goto WinNT perl -x -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9 goto endofperl :WinNT perl -x -S "%0" %* if NOT "%COMSPEC%" == "%SystemRoot%\system32\cmd.exe" goto endofperl if %errorlevel% == 9009 echo You do not have Perl in your PATH. if errorlevel 1 goto script_failed_so_exit_with_non_zero_val 2>nul goto endofperl @rem '; undef @rem; #!perl -w #line 15 # # This batch file runs Perl to open a command.com window and # chdirs to the directory of the item it's called in. # I.e., if it's called on a directory, it chdirs to that. If # it's called on a file, it chdirs to the directory containing # that file. # # This is useful if you make a shortcut to "openc.bat" in your # c:\windows\sendto directory, and call the shortcut "Shell". # That's so you can select any file/dir icon and rightclick, # choose "Send to..." and "Shell" and have it open a shell window # in that directory! # # Handy unrelated tip: to spawn a new command.com window from # inside another one, just run "start command". # my $in = $ARGV[0] || '.'; if(-f $in) { require File::Basename; $in = File::Basename::dirname($in); } elsif(! -d $in) { print "What is $in?\n"; sleep 3; $in = '.'; } #system("start.exe command.com /k chdir \"$in\""); chdir $in or print("Can't chdir to $in : $!"), sleep(5), exit; system("start.exe command.com /k ver"); exit; __END__ :endofperl