Skip to content

Commit

Permalink
* Moved function to swap.exe
Browse files Browse the repository at this point in the history
  • Loading branch information
tryallthethings committed Oct 26, 2020
1 parent 46059d0 commit 9553862
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 40 deletions.
6 changes: 3 additions & 3 deletions DNS-Swapper/DNS-Swapper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.5.2.%2a</ApplicationVersion>
<ApplicationVersion>1.5.3.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
Expand Down Expand Up @@ -192,8 +192,8 @@
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>
</PostBuildEvent>
<PostBuildEvent>del DNS-Swapper.exe
..\..\..\packages\ILRepack.2.0.18\tools\ILRepack.exe /out:"DNS-Swapper.exe" DNS-Swapper-nodll.exe AutoUpdater.NET.dll IPAddressControlLib.dll</PostBuildEvent>
</PropertyGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
Expand Down
35 changes: 0 additions & 35 deletions DNS-Swapper/NetworkManagement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,41 +100,6 @@ public void setGateway(string gateway)
}
}

/// <summary>
/// Set's the DNS Server of the local machine
/// </summary>
/// <param name="NIC">NIC address</param>
/// <param name="DNS">DNS server address</param>
/// <remarks>Requires a reference to the System.Management namespace</remarks>
public static void setDNS(string NIC, string DNS)
{
ConnectionOptions options = PrepareOptions();
ManagementScope scope = PrepareScope(Environment.MachineName, options, @"\root\CIMV2");
ManagementPath managementPath = new ManagementPath("Win32_NetworkAdapterConfiguration");
ObjectGetOptions objectGetOptions = new ObjectGetOptions();
ManagementClass mc = new ManagementClass(scope, managementPath, objectGetOptions);
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
{
if ((bool)mo["IPEnabled"])
{
if (mo["Caption"].ToString().Contains(NIC))
{
try
{
ManagementBaseObject newDNS = mo.GetMethodParameters("SetDNSServerSearchOrder");
newDNS["DNSServerSearchOrder"] = DNS.Split(',');
ManagementBaseObject setDNS = mo.InvokeMethod("SetDNSServerSearchOrder", newDNS, null);
}
catch (Exception e)
{
throw;
}
}
}
}
}

public static IPAddress getDNS(string NICname)
{
NetworkInterface[] networkInterfaces = NetworkInterface.GetAllNetworkInterfaces();
Expand Down
4 changes: 2 additions & 2 deletions DNS-Swapper/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.5.2.0")]
[assembly: AssemblyFileVersion("1.5.2.0")]
[assembly: AssemblyVersion("1.5.3.0")]
[assembly: AssemblyFileVersion("1.5.3.0")]

0 comments on commit 9553862

Please sign in to comment.