Win32::GuiTest::Cmd - Perl Batch File Enhancer. Part of Win32::GuiTest. |
use Win32::GuiTest::Cmd ':ASK';
Pause("Press ENTER to start the setup...");
setup_network() if YesOrNo("Setup networking component?");
$address = AskForIt("What's your new ip address?", "122.122.122.122");
$dir = AskForDir("Where should I put the new files?", "c:\\temp");
copy_files($dir) if $dir;
$exe = AskForExe("Where is your net setup program?", "/foo/bar.exe");
system($exe) if YesOrNo("Want me to run the net setup?");
Instead of writing batch files (although on NT they are almost usable), I've resorted more and more to writing Perl scripts for common sysadmin/build/test chores. This module makes that kind of thing easier.
Other modules I've found useful for that kind of work:
use Win32::NetAdmin;
use Win32::NetResource;
use Win32::ODBC;
use Socket;
use Sys::Hostname;
use File::Path 'mkpath';
use Getopt::Std 'getopts';
Console interaction functions heavily based on the command-line installer for the libwin32 distribution written by Gurusamy Sarathy.
Pause([$message])
YesOrDie([$message])
YesOrNo([$msg])
AskForIt([$question],[$def_value])
IsExe($filename)
AskForExe([$question],[$def_exe])
AskForDir([$question],[$def_dir])
AskAndRun([$question],[$def_exe])
system
.
Mostly allow opening Win32 Control Panel Applets programatically.
RunCpl($applet)
RunCpl("modem.cpl");
Manipulate the registry.
RegisterCom($path)
RegisterCom("c:\\myfiles\\mycontrol.ocx");
UnregisterCom($path)
UnregisterCom("c:\\myfiles\\mycontrol.ocx");
AddToRegistry($regfile)
AddToRegistry("c:\\myfiles\\test.reg");
Sorry about that...
WhichExe($file)
WhichExe("regedit") -> C:\WINNT\regedit.exe WhichExe("regsvr32") -> D:\bin\regsvr32.exe WhichExe("ls") -> D:\Usr\Cygnus\B19\H-i386-cygwin32\bin\ls.exe
Based on original code grabbed from CPAN::FirstTime.
Added support for NT file extension associations:
WhichExe("test.pl") -> perl D:\SCRIPTS\test.pl %* WhichExe("report.ps") -> D:\gstools\gsview\gsview32.exe D:\TMP\report.ps
Ernesto Guisado <erngui@acm.org>, <http://triumvir.org>
Win32::GuiTest::Cmd - Perl Batch File Enhancer. Part of Win32::GuiTest. |