Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • December 08, 2016, 11:54:21 PM
  • Proudly celebrating 10 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: netsh alias problem  (Read 4195 times)

ali79

  • Participant
  • Joined in 2007
  • *
  • default avatar
  • Posts: 6
    • View Profile
    • Donate to Member
netsh alias problem
« on: September 23, 2011, 02:25:55 AM »
Hi, I am trying to get a netsh alias working.

Trying to achieve:

Alias:

dns 8.8.8.8

to launch

netsh interface ip set dns "Local Area Connection" static 8.8.8.8

and if Alias:

dns dynamic

then

netsh interface ip set dns "Local Area Connection" dhcp

As a simple case I have tried putting dns as alias name, leaving all optional and

Change DNS - $$1 | netsh interface ip set dns "Local Area Connection" static $$1

but this doesn't seem to be working. As soon as I type the first number, the alias disappears from result and pressing enter does nothing, like when I try dns 8.8.8.8 with the above alias.

Any ideas?

Also can I prepend runcap with the above alias to get it to display the output?

Thanks!

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 36,421
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: netsh alias problem
« Reply #1 on: September 23, 2011, 09:44:40 AM »
Hi ali,

You are on the right track -- but you want to use a regular expression to capture the 8.8.8.8 stuff

So make your alias called netsh,

But make the regex pattern to match:
^netsh (.*)$

and then you will also need to modify your command to run to specify the full path to the netsh.exe

and yes i think runcap should work fine with this.

See if that's enough to get it solved and maybe post your solution for others if so. if not let me know where you get stuck.

ali79

  • Participant
  • Joined in 2007
  • *
  • default avatar
  • Posts: 6
    • View Profile
    • Donate to Member
Re: netsh alias problem
« Reply #2 on: September 23, 2011, 11:38:56 PM »
Thanks for your answer, never realized the regular expression was there to match the input. So, here's what I have got:

Alias Name : dns
Reg Exp:     ^dns (.*)$
Code:         Change DNS - $$1 | runcap netsh interface ip set dns "Local Area Connection" $$1

This allows me to switch between

dns static 8.8.8.8
and
dns dhcp

I can see that farr now tries to execute this but nothing happens. Anyway to see any logs or to find what the problem is? As the same command runs fine within farr without the alias. I have tried the alias with and without the runcap.

Thanks!

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 36,421
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: netsh alias problem
« Reply #3 on: September 25, 2011, 04:14:17 PM »
dont just put netsh, you have to specify a full commandline path to it.

ali79

  • Participant
  • Joined in 2007
  • *
  • default avatar
  • Posts: 6
    • View Profile
    • Donate to Member
Re: netsh alias problem
« Reply #4 on: September 26, 2011, 01:27:03 AM »
dont just put netsh, you have to specify a full commandline path to it.


netsh was on my path so I thought I would be ok. Giving full path got it working! Thanks!

However, I can't get it to run in runcap. I have tried "runcap dns static 8.8.8.8" but I think runcap thinks dns is a commandline app. Also tried prepending runcap within the alias itself.

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 36,421
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: netsh alias problem
« Reply #5 on: September 26, 2011, 10:33:12 AM »
dont do "runcap dns static"
instead put the runcap in the dns alias before the path to netsh.  So make your dns alias result be something like "runcap c:\windows\system32\netsh.exe" or whatever the path is.

ali79

  • Participant
  • Joined in 2007
  • *
  • default avatar
  • Posts: 6
    • View Profile
    • Donate to Member
Re: netsh alias problem
« Reply #6 on: September 26, 2011, 11:22:30 AM »
Yes, as mentioned in my previous message, I did try doing the runcap in alias. Doesn't work... without it the command atleast works. With runcap in alias the command doesn't even work.

Thanks!
« Last Edit: September 26, 2011, 01:54:43 PM by ali79 »

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 36,421
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: netsh alias problem
« Reply #7 on: September 26, 2011, 11:38:59 AM »
Sometimes I wonder how I manage to forget how to use my own programs...

"runcap" is *not* what you want -- that's an alias that invokes the command you do want: appcapappendmemo

See the help file page Advanced Use->Special/Virtual Launch Strings/Commands:
  • appcap FILEPATH - runs an app and waits for it to finish, redirecting stdio capturing any commandline output in %lastappcap% (normal commandline window is hidden and not shown).
  • appnowait FILEPATH - runs an app and captures output but doesn't wait for it to complete before continuing launch string execution.
  • appcapappendmemo FILEPATH - runs an app and shows output in memo mode as it is outputted by the console program.  If you want to show some custom intro text, call showmemo first before calling this.
  • appcapappendmemons FILEPATH - runs an app and shows output in memo mode as it is outputted by the console program.  If you want to show some custom intro text, call showmemo first before calling this; does not auto scroll to bottom.

If you can't get it to work with one of those -- paste me or attach a screenshot of your alias and i'll try to make it work.

ali79

  • Participant
  • Joined in 2007
  • *
  • default avatar
  • Posts: 6
    • View Profile
    • Donate to Member
Re: netsh alias problem
« Reply #8 on: September 26, 2011, 01:53:22 PM »
Thanks a lot mouser! It's working perfectly!

I am adding a screen shot for reference:

temp.gif

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 36,421
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: netsh alias problem
« Reply #9 on: September 26, 2011, 01:56:34 PM »
Quote
Thanks a lot mouser! It's working perfectly!

Great!  Thanks for your patience and for posting a solution  :up: