Hello World, I have a VBS script I run from time to time when I need to find a Mac or Serial or IP based on the node of a PC. I want to do that from within Access to update the info for a PC in the database. See the script below. On error resume next 'strComputer = Wscript.Arguments.Item(0) strComputer=InputBox ('Enter NODENAME to query for Mac Address') If strComputer = ' Then strComputer='.' (local computer) if no computer-name was entered Set objWMIService = GetObject('winmgmts: ' & strComputer & ' root cimv2') Set colItems = objWMIService.ExecQuery ('Select. From Win32NetworkAdapterConfiguration Where IPEnabled = True') ReDim arrIP(-1) For Each objItem in colItems Wscript.Echo objItem.MACAddress 'Uncomment if you want to display the info macinfo = objItem.MACAddress For Each addr In objItem.IPAddress ReDim Preserve arrIP(UBound(arrIP)+1) arrIP(UBound(arrIP)) = addr Next Next strIP = Join(arrIP, ',') If strComputer = '.' Hi Chris, Since I cannot test this using a working network, give the following a shot and let me know what happens.
![]()
Tried resetting Windows, the modem, but still no luck. I went back and forth between the desktop and their laptop and each time the laptop would work fine but the desktop would not connect. I can only think the Network adapter (NIC) port is faulty.
Public Function GetMACAddress As String 'Modified by [email protected] '10/3/2015 'retrieve computer's MAC address Dim objWMIService As Object Dim colItems As Variant Dim objItem As Variant Dim strComputer As String Dim macinfo As String strComputer = InputBox('Enter NODENAME to query for Mac Address') If strComputer = ' Then strComputer = '.' (local computer) if no computer-name was entered Set objWMIService = GetObject('winmgmts: ' & strComputer & ' root cimv2') Set colItems = objWMIService.ExecQuery ('Select.
From Win32NetworkAdapterConfiguration Where IPEnabled = True') For Each objItem In colItems macinfo = objItem.MACAddress Debug.Print macinfo Next GetMACAddress = macinfo End Function In the Immediate Window, just type: GetMACAddress and then tell me what shows up underneath it. Hey DB guy, I'm hanging up wherever I can. Where do I put it. How do I use it.
Should I place the code in a standard module and call it from the Form? Should I place it in the Form's module?
How should I change the last section to instead of writing to a text file to write into the individual Fields in the Form. What should be changed so that I am using this with VBA from an Access Form and not a VBS from the desktop? Thanks for responding DB guy!!! Just takes a click to give thanks for a helpful post or answer. Please vote “Helpful” or Mark as “Answer” as appropriate.
Chris Ward Microsoft Community Contributor 2012. I tested this out, and it does work with VBA. However, I have a question for you. Since I don't have a network at home, I did not enter any node name to check the MAC address of my computer. I got two message boxes showing two different MAC addresses: one for my WiFi and one for my VM (my NIC is not connected, or I probably would have seen three message boxes). However, when I opened the text file it created, I only saw one MAC address entry.
Is this also what you get when using the script on the network? If so, my question to you for modifying the code for your form is which MAC address do you want returned to your form? I see from the text file that the script returned the last MAC address found. Is that what you want as well? Also, you mentioned something about assigning the values into separate fields on your form.
What do you mean by that? If the MAC address was 1A:2B:3C:4D:5E:6F, did you want the whole thing together or each section one at a time? 1) I tested this out, and it does work with VBA. 2).question for you. Since I don't have a network at home, I did not enter any node name to check the MAC address of my computer.
I got two message boxes showing two different MAC addresses: one for my WiFi and one for my VM (my NIC is not connected, or I probably would have seen three message boxes). However, when I opened the text file it created, I only saw one MAC address entry.
Is this also what you get when using the script on the network? 3) If so, my question to you for modifying the code for your form is which MAC address do you want returned to your form?
I see from the text file that the script returned the last MAC address found. Is that what you want as well? 4) Also, you mentioned something about assigning the values into separate fields on your form. What do you mean by that? If the MAC address was 1A:2B:3C:4D:5E:6F, did you want the whole thing together or each section one at a time? Hi DB guy and thanks again for looking into this with me. 1) Great how did you call it, and even though it did work it seems a bit cumbersome.
Perhaps there is a better method? 2) When you don't specify a computer name (node) then the script looks at the local machine for information. I haven't tried it on Laptops yet as I haven't had the need.
When you say it picked up the WiFi, does that mean it picked up your router? Hadn't tried in there yet either. I always get 1 Mac Address returned unless I have multiple nic cards active on the network from the same machine.
Rare but there are a couple of these. Usually only when additional IP's are enabled. 3) In our case the NIC that is active. The others are locked in the image before distribution. 4) What I need to do is update the existing record for the node. The fields on the Form are using the current record node, find the following IP, mac, Serial. I can get all this with a script but I want to use Access to run from the current Record to update the record with this data as well as a date time stamp of the update.
So I'm guessing I need to have a button on the Form that looks at the Record and says for this records node update the Mac etc. Just takes a click to give thanks for a helpful post or answer. Please vote “Helpful” or Mark as “Answer” as appropriate. Chris Ward Microsoft Community Contributor 2012. Hi Chris, Since I cannot test this using a working network, give the following a shot and let me know what happens.
Public Function GetMACAddress As String 'Modified by [email protected] '10/3/2015 'retrieve computer's MAC address Dim objWMIService As Object Dim colItems As Variant Dim objItem As Variant Dim strComputer As String Dim macinfo As String strComputer = InputBox('Enter NODENAME to query for Mac Address') If strComputer = ' Then strComputer = '.' (local computer) if no computer-name was entered Set objWMIService = GetObject('winmgmts: ' & strComputer & ' root cimv2') Set colItems = objWMIService.ExecQuery ('Select. From Win32NetworkAdapterConfiguration Where IPEnabled = True') For Each objItem In colItems macinfo = objItem.MACAddress Debug.Print macinfo Next GetMACAddress = macinfo End Function In the Immediate Window, just type: GetMACAddress and then tell me what shows up underneath it. Good Morning DB guy, I get the following error in the immediate window when I enter 'GetMACAddress' - Microsoft Visual Basic for Applications - Compile error: Sub or Function not defined - OK Help - If I use,?GetMACAddress a blank row Where GetMACAddress?
Returns - Microsoft Visual Basic for Applications - Compile error: Expected: expression - OK Help - Just takes a click to give thanks for a helpful post or answer. Please vote “Helpful” or Mark as “Answer” as appropriate. Chris Ward Microsoft Community Contributor 2012. From the Help There is no by this name in the current, but there is a by this name. You can call a procedure, but not a variable.
This error has the following cause and solution:. The name of a variable is used as a procedure call. The error may also be caused by misspelling the name of a valid procedure, because that can be misconstrued as an implicitly defined variable. Check the spelling of the procedure name, and make sure the procedure you are trying to call isn't private to another. Just takes a click to give thanks for a helpful post or answer. Please vote “Helpful” or Mark as “Answer” as appropriate.
Chris Ward Microsoft Community Contributor 2012.
I use Windows 7 on my desktop machine and I ran into an annoying problem the other day. I tried to connect to my wireless network at home like I normally do, but could not connect. I kept getting the following error message: Windows is Unable to Connect to the Selected Network Strange problem! I’ve also had this error once before when I first installed Windows 7 on a new computer and it refused to connect to any wireless networks. I tried to recall everything I had done to fix it the previous time and eventually got things working again.
I’ll list out all the methods you can try to fix the wireless connectivity problem. Release/Renew IP Address You can first try to release and renew the IP address in case it’s simply a problem with the IP address. You can do this in one of two ways.
You can try to simply restart the computer or you can run a few commands from the command prompt. Or you can try both. To run the commands, click on Start and then type in CMD into the search box. Press Enter and you’ll get the command prompt dialog. Now simply type these two commands: ipconfig /release ipconfig /renew. You should see something like what I have above in the screenshot, but instead of saying Ethernet adapter, it’ll say Wireless network adapter. If you get some kind of error when trying to release or renew related to DHCP server, then there may be an issue with the wireless router, which is the second thing to try.
Restart Wireless Router The second thing to try is to restart the wireless router, if you can access it. If you’re trying to connect to someone else’s wireless router or a hotspot at an airport, for example, then you obviously won’t be able to do this and the issue could still be with your computer. You can skip this part and read on if this is your scenario. Otherwise, go ahead and turn off the router completely and then wait about 30 seconds and turn it back on. Wireless routers are notorious for having all kinds of strange connection issues and most of the time the problem can be fixed by simply restarting.
Disable Security on Wireless Router Depending on what kind of wireless card you have and the security settings for the wireless router, it could be that you simply cannot connect because the security encryption on the router is too advanced and your network card does not support it. In order to test this, try to turn off or disable the security on the wireless router temporarily to see if you are able to connect. You’ll have to log into your router and go to the wireless settings page and choose either None or Disable. If you are able to connect, then it’s basically a problem with the security settings.
You may have to upgrade the drivers on your network card or you may even have to upgrade to your OS to the latest service pack. For example, make sure you are running Windows XP SP3 in order to connect to the latest wireless routers.
Update Network Card Drivers Also, if there is a security problem between the two devices, you should upgrade the drivers for your network card. The latest drivers may support the higher encryption on the wireless router and therefore allow you to connect.
Even if you bought a computer recently, it’s always a good idea to go directly to the network card manufacture’s website and download the driver from there. You can see the exact model of your network card by going to Start, Control Panel, System and clicking on Device Manager in the left menu.
Expand Network adapters and you’ll get a list of all the network adapters on the computer. It should have the company and the model number in the list itself. Make sure you install the correct version depending on what operation system you are running. Turn on Network Discovery There are occasions when somehow settings get changed on your computer and you have no idea how. One of those could be Network Discovery, which lets Windows talk and connect to other computers and network devices. To make sure it’s turned on, go to Control Panel and click on Network and Sharing Center. In the left pane, click on Change advanced sharing settings. Now make sure that the radio button for Turn on network discovery is selected.
If it was turned off for any reason, that could have been causing the issue where you could not connect to a wireless network or even an issue where you could not see the wireless network at all in the list. Use Network Troubleshooter Windows has a nifty little troubleshooting tool in Windows 7 that can possibly fix your problem too. It’s called the Network Troubleshooter and you can access it by right-clicking on the wireless icon in your task bar and choosing Troubleshoot Problems.
A dialog will pop up and try to detect any network problems. If this doesn’t fix your problem, then continue reading and hopefully you’ll find a solution soon! Windows XP and Shared Encryption If you’re having this issue on Windows XP, then it could be an issue where the wireless router is open shared encryption instead of open encryption. You can get around this by manually adding the wireless network to your computer. To do this, go to Control Panel and then Network Connections. Right-click on the wireless network adapter and choose Properties.
Then, click on the Wireless Networks tab and click the Add button. Finally, go ahead and type in the SSID for the wireless router and set the Network Authentication to Shared. BY default it is set to Open like in the image below, so you have to change it to Shared. Also, uncheck the box that says “ This key is provided for me automatically“.
Manually type in the network key and click OK. If this was the issue, you will now be connected to the wireless network. It’s a little annoying, but it works. So it nothing else is working for you and you’re not sure what type of encryption the router is using and you’re on Windows XP, give this a shot. Wireless USB Adapters If you’re using a wireless dongle or one of those wireless adapters that connects to a computer via USB, then your issue is probably related to the device itself. Those USB wireless adapters tend to have issues since it’s connected via USB. Here’s a couple of things you can try for these types of adapters: 1.
Turn off your computer completely and unplug it! Yes, unplug it! Then turn it back on and see if you are able to connect. Try using a different USB port for the wireless adapter. Uninstall all USB devices from Device Manager and then let the computer reinstall them 4.
Update the drivers for the USB adapter Uninstall Security Software As a last resort, your problem could be related to some kind of security software. This is especially true for company computers that have Symantec Endpoint Protection or some other insane security software. If you can, try uninstalling it and seeing if that fixes your issue. Other programs to try and uninstall include Microsoft Security Essentials and any kind of Norton software. If you find that was the problem, try a different product or try to reinstall it.
Those are pretty much all the possible solutions I could find on this particular wireless issue. If something else worked for you, post a comment here and let us know! If you’re still having issues, tell us your setup and we’ll try to help.
Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |