List Installed Modems
Keywords:
Question:
I am looking for a way to determine what modems are installed on a computer so that I can create a connectoid - a way of doing a AskItemList of installed modems. The problem is that there doesnt seem to be any consistent way of determining it in the different OS's (even within OS's they arent always in the same place - and again between laptops and desktops within the same OS's). I dont have a problem writting seperate installs for each OS (thanks to WinMetrics) but I cant determine how to tell what they are, and as I understand it I cant create a connectoid without being able to specify a RasEntrySet("devicename",devicename) and RasEntrySet("autodialDll","") would be OK but it still needs the devicename anyway.Answer:
Currently WinBatch doesn't offer any direct functions that can retrieve a list of installed modems. However I understand the following code should work with Windows 95/98/ME/NT40/2000/XP.#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) exitWinBatch 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