Jump to content

Mickmix69

Member
  • Posts

    3
  • Joined

  • Last visited

  • Donations

    0.00 USD 
  • Country

    France

About Mickmix69

Mickmix69's Achievements

0

Reputation

  1. Thank you i will use it sure! However, I succeed to write a vbs script in order to list network adapter and to change a pre-defined IP configuration : Msgbox "Cette application permet de switcher la config IP de la carte Réseau Ethernet" & chr(13) & _ "entre l'adressage par DHCP et un adressage statique Compatible avec le FSU." & chr(13) & chr(13) & _ "Version de soft : 1.0.1" & chr(13) & "Auteur : Michael VALLET", vbinformation, "Infos" main Sub Main dim strComputer dim Carte(50) dim saisie dim i, j, a on error resume next strComputer = "." Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colNetAdapters = objWMIService.ExecQuery ("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE") strIPAddress = Array("192.168.11.10") strSubnetMask = Array("255.255.255.0") 'strGateway = Array("192.168.5.190") 'strDNSServers = Array("97.20.255.254") strGatewayMetric = Array(1) carte(0) = "" i = 1 For Each objNetAdapter in colNetAdapters carte(i) = objNetAdapter.caption i = i + 1 Next i = i - 1 for j = 1 to i Carte(0) = carte(0) & j & " --> " & carte(j) & chr(13) & chr(13) next carte(0) = carte(0) & chr(13) & chr(13) & "Taper E pour ouvrir directement l'explorateur FSU" saisie = inputbox(carte(0),"Choix de la carte Réseau") if saisie = "" then exit sub 'if saisie > i then main if saisie = "E" or saisie = "e" then Set WshShell = CreateObject("WScript.Shell") Set oExec = WshShell.Exec("explorer \\192.168.11.11\Dossier_partager") exit sub end if ChoixConfig = inputbox("Quelle config voulez vous charger?" & chr(13) & chr(13) & "1 --> DHCP Alstom" & chr(13) & "2 --> FSU","Choix de la Config IP") if ChoixConfig = "" then exit sub if choixConfig > 2 then main If choixConfig = "1" then For Each objNetAdapter in colNetAdapters if objNetAdapter.caption = carte(saisie) then 'msgbox objNetAdapter.caption & " ok, on rentre dans le IF" errEnable = objNetAdapter.EnableDHCP 'EnableStatic(strIPAddress, strSubnetMask) 'errGateways = objNetAdapter.SetGateways(strGateway, strGatewaymetric) 'errDOM = objNetAdapter.EnableDNS'SetDNSServerSearchOrder(strDNSServers) end if next if errEnable = 0 Then WScript.Echo "L'addresse IP a été changée correctement." Else WScript.Echo "L'addresse n'a pas été changée il y a un Pb." End If end if If choixConfig = "2" then For Each objNetAdapter in colNetAdapters if objNetAdapter.caption = carte(saisie) then WScript.Echo "L'ordinateur se connecte. Veuillez quelques secondes...." errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask) 'errGateways = objNetAdapter.SetGateways(strGateway, strGatewaymetric) 'errDOM = objNetAdapter.EnableDNS'SetDNSServerSearchOrder(strDNSServers) end if next if errEnable = 0 Then WScript.Echo "L'addresse IP a été changée correctement." Set WshShell = CreateObject("WScript.Shell") Set oExec = WshShell.Exec("explorer \\192.168.11.11\Dossier_partager") Else WScript.Echo "L'addresse n'a pas été changée il y a un Pb." End If end if end sub Thank you for your reactivity
  2. Ok, thanks a lot. It works but separately. I think i'm going tu use C to do this. I don't know enough vbs or bat languages. I will use the vbscript idea in the C code. If it works i will post it ... Thank you ^^
  3. HEllo all, I'm writting a batch file to allow IP configuration change. I use netsh : (netsh interface ip set address "EThernet" static 192.168.11.10 255.255.255.0) My problem is : I have to know the network adapter name. So if it's wrong I'd like To change it by selecting it in a list (in a dos window) for exemple : ------------------------------------------------ list of network adapter name : 1 - Wireless broadcom.... 2- Ethernet Gigabyte adpater.... 3- EThernet Broadcom3 adpater.... What is your choice ? (enter the number of the network adapter) ----------------------------------------------- I think I should use the Win32_NetworkAdapter class but I don't know how i ould use it below the code i've just written : setlocal enabledelayedexpansion title "Changer la configuration IP" echo Changement de la Configuration IP vers la config FSU............ netsh interface ip set address "Ethernet" static 192.168.11.10 255.255.255.0 if errorlevel 1 ( echo Problem, select the network adapter rem strComputer = "." rem Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapter") pause For Each objItem in colItems Wscript.Echo "Name: " & objItem.Name Wscript.Echo Next set /p Your choice : netsh interface ip set address objItem.Name static 192.168.11.10 255.255.255.0 ) Thanks a lot PS : Sorry for my poor english
×
×
  • Create New...