Results 1 to 7 of 7

Thread: Batch Files

  1. #1
    3 Star Lounger Not Brightest Bulb's Avatar
    Join Date
    Dec 2009
    Location
    Central IL
    Posts
    376
    Thanks
    69
    Thanked 4 Times in 4 Posts

    Batch Files

    A while back I asked for assistance in turning my Win 7 Broadband on and off, I got some guidance about desktop Batch files to get the job done and installed my very 1st batch files. They worked great till yesterday and for whatever reason I could not turn broadband off. I tried a reboot and that did not help, I deleted the disable batch and redid it and still no success. I did a reboot after that install and that did not help. So I decided to leave it alone till this morning shut down the PC and when I fired it up this morning both enable and disable batch file were back working as they should. I'm not use to this because when Murphy's law slaps me I usually stay slapped for a longer period of time. Any ideas.

  2. #2
    5 Star Lounger
    Join Date
    Jan 2010
    Location
    Los Angeles, CA
    Posts
    828
    Thanks
    4
    Thanked 38 Times in 34 Posts
    Could you post the batch files? Apparently, whatever command they ran just didn't work for some reason.

  3. #3
    3 Star Lounger Not Brightest Bulb's Avatar
    Join Date
    Dec 2009
    Location
    Central IL
    Posts
    376
    Thanks
    69
    Thanked 4 Times in 4 Posts
    Quote Originally Posted by cafed00d View Post
    Could you post the batch files? Apparently, whatever command they ran just didn't work for some reason.
    Below are files and they are still firing up as they should because now they got me nervous so I give them a try just to check-em. I believe my new PC just likes to see if I'm paying attention. It does not realize I have WSL covering my back.

    wmic path win32_networkadapter where index=7 call enable
    wmic path win32_networkadapter where index=7 call disable

  4. #4
    WS Lounge VIP
    Join Date
    Dec 2009
    Location
    Earth
    Posts
    8,191
    Thanks
    48
    Thanked 985 Times in 915 Posts
    You are using an index to the adapter, so if Windows decides the adapter is now index 6 the batch file won't work.
    Personally I reckon it's easier to pull the network cable.

    cheers, Paul

  5. #5
    3 Star Lounger Not Brightest Bulb's Avatar
    Join Date
    Dec 2009
    Location
    Central IL
    Posts
    376
    Thanks
    69
    Thanked 4 Times in 4 Posts
    Geeeze!

    That's easy but no fun at all, because of fooling around I learned how to put a batch file on desktop which was kinda cool. Besides that with my PC setup I would have to become a contortionist every time I want to disconnect.

  6. #6
    5 Star Lounger
    Join Date
    Jan 2010
    Location
    Los Angeles, CA
    Posts
    828
    Thanks
    4
    Thanked 38 Times in 34 Posts
    Try this using PowerShell.

    First, get all the network adapters by entering:
    get-wmiobject win32_networkadapter

    Scan the resulting list for the adapter in question. As an example, I'll use my wireless adapter:

    ServiceName : rt61x64
    MACAddress :
    AdapterType :
    DeviceID : 14
    Name : Linksys Wireless-G PCI Adapter
    NetworkAddresses :
    Speed :

    The adapter is currently disabled, that is why the MACAddress and Speed are empty. Pick any of the property values that is unique. For this adapter either the ServiceName or Name would work. But I noticed that among the various adapters that the Name is usually unique, so I'll pick that. The PowerShell command to select just that one adapter is:
    get-wmiobject win32_networkadapter -Filter 'Name = "Linksys Wireless-G PCI Adapter"'

    Now that you have that one adapter, you can enable it using this command:

    (get-wmiobject win32_networkadapter -Filter 'Name = "Linksys Wireless-G PCI Adapter"').enable()

    and disable it using:

    (get-wmiobject win32_networkadapter -Filter 'Name = "Linksys Wireless-G PCI Adapter"').disable()


    To run this from a batch file, into the batch file place this one line for enable (the disable one is similar):

    powershell -noprofile -noninteractive -command (get-wmiobject win32_networkadapter -Filter 'Name = \"Linksys Wireless-G PCI Adapter\"' ).enable()


    Now you don't have to rely on the index always being the same. BTW, your browser might wrap the command lines - but they are always on a single line.

  7. #7
    3 Star Lounger Not Brightest Bulb's Avatar
    Join Date
    Dec 2009
    Location
    Central IL
    Posts
    376
    Thanks
    69
    Thanked 4 Times in 4 Posts
    Well the heart attack I had after reading the above reply has put an end to any more batch filing. You definitely do not understand the caliber of the man (NBB) you are dealing with.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •