Newbie: Carn`t figure this one out:(

  • Thread starter Thread starter Merlin
  • Start date Start date
M

Merlin

Hey Group,

Could somebody tell me why this command won`t work:

retval = Shell("Netsh int ip set add name="Local Area Connection"
source=static addr=10.12.220.254 mask=255.255.0.0 gateway=10.12.200.1
gwmetric=1, vbNormalFocus")

VB is telling me it expects a ")" after Local, however its a command line
argument and won`t work if I do that:(

Please Help
Many Thanks
Merlin
 
The problem is with your quotes. You can't use a standard double quote
inside a string, because it thinks that is the termination of the string.
However, you can escape your internal double quotes by using two in a row,
like I have done below. You also didn't end the string at the correct
point, you included the , vbNormalFocus as part of your string. I corrected
this in the example below too:

(code may wrap lines, but should all be on one line)

retval = Shell("Netsh int ip set add name=""Local Area Connection""
source=static addr=10.12.220.254 mask=255.255.0.0 gateway=10.12.200.1
gwmetric=1", vbNormalFocus)

Ryan Gregg
 
It worked

Many Thanks, just one question tho, can i get it so a form (or Something)
loads, saying please wait, then responds when the command has run, or even a
timer of say 20 seconds has elapsed it says complete, with a OK button which
will then close the form and goes back to the main menu?

Many thanks again
Merlin
 
Well, I'm assuming that you're using VB.NET (since you're in the dotnet
groups). Yes, there's a pretty easy way to go about doing that. If you
created a new form in your product, and customized it to say whatever you
wanted it to say (we'll pretend it's called FormWait). Then you could do
this instead:

Dim dlgWait As New WaitForm
dlgWait.TopMost = True
dlgWait.Show()

Dim proc As New System.Diagnostics.Process
proc.StartInfo.FileName = "netsh"
proc.StartInfo.Arguments = "int ip set add name=""Local Area Connection""
source=static addr=10.12.222.254 mask=255.255.0.0 gateway=10.12.200.1
gwmetric=1"
proc.Start()
proc.WaitForExit()

dlgWait.Hide()
dlgWait = Nothing
 
Back
Top