Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords:
#DefineFunction ListModems() modemlist ="" OSver_major = ItemExtract(1,WinVersion(5),"-") If OSver_major == 2 ;Windows NT/2000/XP keypath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Unimodem\DeviceSpecific" If RegExistKey(@REGMACHINE,keypath) keys=RegOpenKey(@REGMACHINE,keypath) keylist=RegQueryKeys(keys) RegCloseKey(keys) If keylist=="" then return modemlist For count=1 to ItemCount(keylist,@TAB) modem=ItemExtract(count,keylist,@TAB) modemname = ItemExtract(1,modem,"::") modemlist = StrCat(modemlist,@TAB,modemname) next Else return modemlist EndIf Endif If OSver_major == 1 ;Windows 95/98/ME keypath = "System\CurrentControlSet\Services\Class\Modem" If RegExistKey(@REGMACHINE,keypath) keys=RegOpenKey(@REGMACHINE,keypath) keylist=RegQueryKeys(keys) RegCloseKey(keys) If keylist=="" then return modemlist For count=1 to ItemCount(keylist,@TAB) modemnum=ItemExtract(count,keylist,@TAB) modemname = RegQueryValue(@REGMACHINE, StrCat(keypath,"\",modemnum,"[DriverDesc]")) modemlist = StrCat(modemlist,@TAB,modemname) next Else return modemlist EndIf Endif modemlist = StrTrim(modemlist) Return modemlist #EndFunction list = ListModems() modem = AskItemList("List of Installed Modems", list,@tab,@unsorted,@single) exit
WinBatch 2002E, will offer WMI support. With the added support of WMI, you should be able to get a list of modems using the following code:
Locator = ObjectOpen("WbemScripting.SWbemLocator") Service = Locator.ConnectServer() Security = Service.Security_ Security.ImpersonationLevel = 3 modem_collection = Service.InstancesOf("Win32_POTSModem") hEnum = ObjectCollectionOpen(modem_collection) list = "" While 1 modem = ObjectCollectionNext(hEnum) If modem == 0 Then Break desc = modem.Description deviceType = modem.DeviceType list = StrCat(list,@tab,desc,"|",devicetype) EndWhile list = StrTrim(list) modeminfo = AskItemList("List of modems",list,@tab,@unsorted,@single) Message("Modem name|Type Chosen",modeminfo) ObjectCollectionClose(hEnum) ObjectClose(modem_collection) ObjectClose(Security) ObjectClose(Service) ObjectClose(Locator)
Article ID: W15166
File Created: 2002:09:05:13:50:12
Last Updated: 2002:09:05:13:50:12