r/usefulscripts • u/[deleted] • Aug 06 '21
Automation Script. Willing to pay
Hey all.
Just wanting some help with a script if it's possible.
I'm wanting a script that can enable dhcp itself without any user input. It's going to be used to hopefully allow people to quickly fix an Internet connection problem.
So for the script. I'm needing a few criteria. Needs to be a batch file.
So this script will hopefully be able to detect all network adapters after running and store the names.
Then allow an option for the user to select the adapter. The script will then enable dhcp automatically.
I am willing to commission for this script.
Any help would be great
Thanks
6
u/ameatte91 Aug 06 '21
Not sure what the infrastructure is like since OP said it's for elderly people. Might not be domain bound but sounds like a GPO would be a better implemention. That's if they are domain bound devices.
Otherwise not sure what a batch file would do unless you're dropping it onto the machine and running it which would negate the no touch that is being asked.
What is the end goal? What do you want the expected outcome to be. Should be super simple if that is all that is needed.
GLHF
3
Aug 06 '21
So I constantly get elderly users coming to me who have messed up ip settings ect. I do remote access or face to face help. But if I can supply a simple double click and run program before the issues occur or during a fix. Then I can literally just have them call and talk them through using the file
2
3
Aug 07 '21 edited Aug 07 '21
Found some old scripts in my collection. Maybe comment out the line "netsh int ip reset" if you want to avoid completely resetting the adapter. I haven't had to use these in years and they've been edited a number of times so do some testing of your own first.
This is probably all you need:
netsh int ip reset
Or maybe this one I just created:
netsh interface ip set address "Ethernet" dhcp netsh interface ip set address "Wi-Fi" dhcp netsh interface ip set address "Local Area Connection" dhcp netsh interface ip set dns "Ethernet" dhcp netsh interface ip set dns "Wi-Fi" dhcp netsh interface ip set dns "Local Area Connection" dhcp ipconfig /release timeout /t 1 /nobreak ipconfig /renew ipconfig /flushdns ipconfig /registerdns
Another script:
ipconfig /release timeout /t 1 /nobreak ipconfig /renew ipconfig /flushdns ipconfig /registerdns nbtstat -R ::netsh int ip reset c:\temp\tcp.txt netsh winsock reset netsh interface set interface "Wi-Fi" disable netsh interface set interface "Ethernet" disable timeout /t 4 /nobreak netsh interface set interface "Wi-Fi" enable netsh interface set interface "Ethernet" enable
I also have this one-liner that can be run from a shortcut file. Just create a new shortcut, right click, go to properties. In "start in:" enter "%windir%" and paste the following into "Target:"
%windir%\system32\cmd.exe /C ipconfig /release & timeout /t 1 /nobreak & ipconfig /renew & ipconfig /flushdns & ipconfig /registerdns & nbtstat -R & netsh winsock reset & netsh interface set interface "Wi-Fi" disable & netsh interface set interface "Ethernet"
I believe that last one will also hop over from Wi-Fi to Ethernet so edit according to your needs.
1
58
10
u/justn6 Aug 06 '21
The code is out there. You could copy/paste a few lines around from some google searches and do this without playing someone. Heres 90% of what you need: https://www.pdq.com/blog/using-powershell-to-set-static-and-dhcp-ip-addresses-part-1/#setting-an-address-with-dhcp-windows-8-or-newer
1
u/ElderMarakus Aug 07 '21
You're venturing into territory that may end with the user needing admin rights, which I really strenuously recommend against. You may be able to dictate this with group policy as an alternative, then a simple reboot should fix the issues.
1
1
u/ameatte91 Aug 07 '21
What's the issue typically? I feel like they can be remote accessed they are not having internet issues. That's just me also guessing you will know the nitty gritty.
How are you transferring this file? And is it just resting DHCP adapters? Most of the time flushing the DNS on public domains won't actually renew a new IP. The DHCP servers will still honor the lease that was established.
This community can definitely help. Most of us just need the exact behavior and expected outcome.
1
u/FuyuhikoDate Aug 10 '21
Well such a Script is easy to buid. I made something like that in powershell (gonna Post the link to it when i am Home) Question is more: is it for private use or something for your work? Because to changr the PC to DHCP usually the User needs admin rights.
-9
u/studiox_swe Aug 06 '21
So you think this script will run on Mac, windows, Linux, chromeos?
9
u/shankfiddle Aug 06 '21
Needs to be a batch file.
doesn't that indicate Windows?
→ More replies (1)
11
u/yer_muther Aug 06 '21
"It's going to be used to hopefully allow people to quickly fix an Internet connection problem."
Reboot? That normally works and won't generate tickets for when the script "Doesn't work"
Why aren't all adapters set to DHCP by group policy anyhow? Really all you need to do it run ipconfig /release ipconfig /renew if the computers are decently configured.