(view source code of bkmdmdrv.rex as plain text)
/* Backup modem driver files with DEVCON *//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *//* Sample DEVCON output: *//* *//* PCI\VEN_127A&DEV_1035&SUBSYS_1035127A&REV_08\4&11CD5334&0&48F0 *//* Name: CXT1035 - HCF PCI Modem *//* Driver installed from c:\winnt\inf\oem8.inf [Modem]. 2 file(s) used by driver: *//* C:\WINNT\system32\DRIVERS\winachcf.sys *//* C:\WINNT\system32\cxt1035.cty *//* 1 matching device(s) found. *//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */"@ECHO OFF"Trace Off
/* Check OS type (should be 32 bits Windows)*/Parse Upper Source os .
If os <> "WIN32" Then Call Syntax
/* Check command line arguments */Parse Arg test
If test <> "" Then Call Syntax
/* Initialize RexxUtil library */If RxFuncQuery( "sysloadfuncs" ) <> 0 Then Do
initRc = RxFuncAdd( "sysloadfuncs", "RexxUtil", "sysloadfuncs" )
If initRc = 0 Then Do
Call sysloadfuncs EndElse Do
SaySay "Error "||initRc||" while trying to initialize RegUtil (RexxUtil)"
SaySay "This script requires Patrick TJ McPhee's RegUtil library,"
Say "available at http://www.interlog.com/~ptjm/"
SaySay "Do yo want to download it now? [y/N]"
Saydownload = Translate( SysGetKey( "NOECHO" ) )
If download = "Y" Then Do
Address SYSTEM "http://www.interlog.com/~ptjm/"
Say "Install the downloaded library file and try again."
EndElse Do
Say "Download and install the library and try again."
EndExit 1
EndEnd/* Check DEVCON's availability */Address SYSTEM "DEVCON.EXE /? >NUL 2>&1"
If rc <> 0 Then Do
SaySay "This script requires Microsoft's DEVCON.EXE, available at"
Say "http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q311272"
SaySay "Do yo want to download it now? [y/N]"
Saydownload = Translate( SysGetKey( "NOECHO" ) )
If download = "Y" Then Do
Address SYSTEM "http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q311272"
Say "Install the downloaded file and try again."
EndElse Do
Say "Download the tool and try again."
EndExit 1
End/* Use DEVCON to retrieve info, and store it in an array */Address SYSTEM 'DEVCON.EXE DriverFiles =Modem 2>NUL | RXQUEUE'
empty = 0
Do i = 1 By 1 Until Queued( ) = 0
Parse Pull line.i
line.i = Strip( line.i, "B", " " )
If line.i = "" Then Do
empty = empty + 1
if empty > 5 Then Leave
End line.0 = iEnd/* Interpret DEVCON's output line by line */nextLine = "ID"
fileCount = 0
driver. = ""
driver.0 = 0
j = 0
Do i = 1 By 1 To line.0
SelectWhen Pos( "matching device(s) found.", line.i ) > 0 Then Leave i /* Last line of output */
When nextLine = "ID" Then Do /* First line for driver */
Parse Value line.i With root"\"str1"&"str2"\"str3
If str3 <> "" Then Do
j = j + 1
driver.0 = jdriver.j.0 = 0
nextLine = "Name"
End EndWhen nextLine = "Name" Then Do /* Line with device name */
Parse Value line.i With "Name: "name
If name <> "" Then Do
name = EscName( name )
driver.j = name
k = 0
nextLine = "inf"
End EndWhen nextLine = "inf" Then Do /* Line with inf file name */
Parse Value line.i With "Driver installed from "inf" ["key"]. "numFiles" file(s) used by driver:"
If numFiles <> "" Then Do
k = k + 1
driver.j.k = inf driver.j.0 = knextLine = "files"
End EndWhen nextLine = "files" Then Do /* Actual driver files */
Parse Value line.i With file
If file <> "" Then Do
k = k + 1
If k = numFiles + 1 Then Do
nextLine = "ID"
End driver.j.k = file driver.j.0 = k End EndOtherwise Nop
EndEnd/* Create a target "root" directory */If SysMkDir( "Modem" ) <> 0 Then Do
Call SysFileTree "Modem", "exist.", "D"
If exist.0 <> 1 Then Do
Say "Error creating directory Modem"
Exit 1
EndEndDo i = 1 By 1 To driver.0
Say "Backing up drivers for modem "||driver.i
/* Create a subdirectory with the device name */If SysMkDir( "Modem\"||driver.i ) <> 0 Then Do
Call SysFileTree "Modem\"||driver.i, "exist.", "D"
If exist.0 <> 1 Then Do
Say "Error creating directory Modem\"||driver.i
Exit 1
End EndDo j = 1 To driver.i.0
driverFile = driver.i.jDo Until driverFile = ""
Parse Value driverFile With dummy"\"driverFile
End driverFile = dummycopyRc = SysCopyObject( driver.i.j, "Modem\"||driver.i||"\"||driverFile )
If copyRc <> 0 Then Do
Say "Error "||copyRc||" while copying "||driver.i.j
Exit 1
End EndEndSay "Your modem drivers are now stored in the directory Modem"
/* Done */Exit 0
EscName: procedure
name = Arg( 1 )
name = Translate( name, "", "|" )
name = Translate( name, "", "?" )
name = Translate( name, "", ":" )
name = Translate( name, "", ";" )
name = Translate( name, "", "," )
name = Translate( name, "", "/" )
name = Translate( name, "", "\" )
name = Translate( name, "[", "(" )
name = Translate( name, "]", ")" )
name = Translate( name, "and", "&" )
Return name
Syntax:
SaySay "BkMdmDrv, Version 1.00 for Windows 2000 / XP"
Say "Backup driver files for every modem installed"
SaySay "Usage: BKMDMDRV.REX"
SaySay "Note: This script requires Microsoft's DEVCON.EXE, available at"
Say " http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q311272"
Say " This script also requires Patrick TJ McPhee's RegUtil,"
Say " available at http://www.interlog.com/~ptjm/"
Say " You will be prompted for download if either isn't found."
SaySay "Written by Rob van der Woude"
Say "http://www.robvanderwoude.com"
Exit 1
Returnpage last modified: 2025-10-11; loaded in 0.0093 seconds