cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
dinesh_redhawk
Level 6

how to detect network cards through Installshield

Hello Guys,

How can i detect network cards [NIC] using Installshield [Any setting/ installscript]?
I need to detect how many NICs are present on the host machine and perform some actions accordingly.
Please guide.
Thanks
Labels (1)
0 Kudos
(7) Replies
chad_petersen
Level 9

If nothing else you could write a C# DTF managed custom action as described here. You would need to install WiX (free) and have Visual Studio (I use 2015) in order to write these types of DLLs.

http://blog.deploymentengineering.com/2008/05/deployment-tools-foundation-dtf-custom.html

Then you would just write the code in a C# Custom Action Project (includes the special [CustomAction] attribute in the C# code) to detect the network cards and the Session object to set properties that your installer can use to know what the C# has found. For example, you could set an MSI Property to a value of the number of network interface cards found.

In InstallShield you link the DLL in by choosing the New MSI DLL...Stored in Binary table" for example and this links it in and exposes your methods for use.

Then you can start using code like this in your installers. The IS_SQLSERVER_AUTHENTICATION comes from the MSI - so you can get and set properties very easily using this technique.

try
{
session["SYSADMIN"] = "false";

string SQLServerAuth = session["IS_SQLSERVER_AUTHENTICATION"];
if (string.IsNullOrEmpty(SQLServerAuth))
{
session["IS_ERROR"] = "SQLAUTHBLANK";
session["SYSADMIN"] = "false";
return ActionResult.Success;
}
else
{
session.Log(SQLServerAuth);
AuthMode = Convert.ToInt32(SQLServerAuth);

}
...


I hope that helps.

Chad

0 Kudos
rguggisberg
Level 13

Another way would be to execute the SystemInfo command and write the output to a file. Then do an InstallScript CA that parses the output looking for the NIC info (typically at the end) and set a property or do whatever you need to do based on the results.
0 Kudos
Cary_R
Level 11

Whatever language you use, you should check out the Win32_NetworkAdapter class in WMI. You should be able to easily query this and iterate through the adapters.

https://msdn.microsoft.com/en-us/library/aa394216(v=vs.85).aspx

VBScript, C#, Powershell, whatever should work fine for this task.

0 Kudos
chad_petersen
Level 9

My next door neighbor wrote a good portion of WMI and he's an idiot. Lol

Couldn't help but notice this.

The Win32_NetworkAdapter class is deprecated. Use the MSFT_NetAdapter class instead.

Might be fair warning.

Most important - have fun doing it

Chad
0 Kudos
dinesh_redhawk
Level 6

rguggisberg wrote:
Another way would be to execute the SystemInfo command and write the output to a file. Then do an InstallScript CA that parses the output looking for the NIC info (typically at the end) and set a property or do whatever you need to do based on the results.


Hi, the SystemInfo command doesnt support detection of NIC information. If you are sure that it does, then kindly provide some more details about it. A code snippet will be more helpful.
Thanks
0 Kudos
rguggisberg
Level 13

When you execute SYSTEMINFO from a CMD prompt the 'Network Card(s):' info appears at the end. You can pipe the output to a file and then parse it to pull out what you want. My output looks something like this:

Network Card(s): 4 NIC(s) Installed.
[01]: Realtek PCIe GBE Family Controller
Connection Name: Local Area Connection
DHCP Enabled: No
IP address(es)
[01]: xxx.xxx.0.xxx
[02]: Juniper Network Connect Virtual Adapter
Connection Name: Network Connect Adapter
Status: Media disconnected
[03]: HP 802.11b/g Wireless Network Adapter
Connection Name: Wireless Network Connection
Status: Media disconnected
[04]: PANGP Virtual Ethernet Adapter
Connection Name: Local Area Connection 2
Status: Media disconnected
0 Kudos
dinesh_redhawk
Level 6

rguggisberg wrote:
When you execute SYSTEMINFO from a CMD prompt the 'Network Card(s):' info appears at the end. You can pipe the output to a file and then parse it to pull out what you want. My output looks something like this:

Network Card(s): 4 NIC(s) Installed.
[01]: Realtek PCIe GBE Family Controller
Connection Name: Local Area Connection
DHCP Enabled: No
IP address(es)
[01]: xxx.xxx.0.xxx
[02]: Juniper Network Connect Virtual Adapter
Connection Name: Network Connect Adapter
Status: Media disconnected
[03]: HP 802.11b/g Wireless Network Adapter
Connection Name: Wireless Network Connection
Status: Media disconnected
[04]: PANGP Virtual Ethernet Adapter
Connection Name: Local Area Connection 2
Status: Media disconnected


Thanks for the clarity. Does the same information can be collected by any of SYSINFO property in Installshield? I tried to search but couldnt find.

However, I achieved my requirement by running the following attached CMD file. I feel anyone can make use of it.
0 Kudos