0

Well i figure that if i do a temp. batch file for a small project heres the batch script.
IPAddy would = a number xx.xx also how to execute from a button and run as admin at the same time.

@echo off
netsh interface ipv4 set address "local Area Connection" static 10.IPAddy.2
2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by mrclark
0
imports system.io

try this
call the sub on a button, and input your ipaddress to pass to the function.
after the file runs you will need to delete the file
if you delete it to early it will not complete running.

and your command is incorrect..

Private Sub CRDBat(ByVal IPAddy As String)

        'Create/Runs/Deletes A Batch File For NETSH

        Dim StreamWriter As StreamWriter
        StreamWriter = File.CreateText("C:\ThisIsYourBatch.bat")
        StreamWriter.WriteLine("@echo off")
        StreamWriter.WriteLine("netsh interface ipv4 set address" & Chr(34) & "Local Area Connection" & Chr(34) & "static 10." & IPAddy & ".2")
        StreamWriter.WriteLine("pause")
        StreamWriter.Close()
        Shell("C:\ThisIsYourBatch.bat")

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        CRDBat("10.4")

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        File.Delete("C:\ThisIsYourBatch.bat")

    End Sub
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.