Jump to content

[WIP] The Lazy Man's All-in-One Batch File v0.02

You_are_a_cunt

For ages I've been using the command line in Windows to do stuff faster/easier or just for stuff that can't be done otherwise without downloading some shady piece of (possibly) malware-ridden software from an equally shady website.

 

Since I usually don't do anything productive for the second half of the working week, I decided to actually compile the commands I use most frequently into a master-batch file so I don't have to remember every single one of them or spend time on Google trying to figure out how to do certain things.

 

One of the reasons I decided to go the way of the .bat is code transparency (and me having forgotten most of what programming I've learned throughout the years) and the fact that the command line doesn't have much in the way of dependencies (you would be able to run it on the freshest of Windows installs without having to download .NET/whatever).

 

This is a fresh project and will be rather periodically updated as I work on it. Since it's in its early infancy, features will be scarce and some kinks will eventually need to be ironed out. I won't be releasing a .bat file quite yet so if you want to use it you'll have to just paste together the code into any text editor and save it as a .bat file.

 

The way I intend to present/explain how it works will be in a "modular" fashion, taking things piece by piece and explaining what it does and why I chose to do it in a particular way if necessary.

 

I am open to suggestions for improvements, alternative methods and things to add.

 

Part 1: The menu

 

Upon launching the .bat file you will be greeted by this menu (which will be updated as more things are added)

ECHO OFFTITLE I'm too lazy to think of a proper title right now:MENU ECHO. ECHO MAIN MENU ECHO. ECHO 1. SET SHUTDOWN/RESTART/HIBERNATE COUNTDOWNECHO 2. NETWORKECHO X. EXIT SET /P M=0  IF %M%==1 GOTO SRHIF %M%==2 GOTO NETWORKIF %M%==X GOTO EXIT:EXITexit

Part 2: The Shutdown/Restart/Hibernate countdown

 

Once into this sub-menu you'll be facing 3 options of setting a "countdown" to shut down, reboot or hibernate your computer. This is being done by inputting your desired timeout period (in seconds) after which the specified action will take place.

:SRHECHO. ECHO SHUTDOWN, RESTART OR HIBERNATE COUNTDOWNECHO. ECHO SET SHUTDOWN - 1 ECHO SET RESTART - 2 ECHO SET HIBERNATE - 3 ECHO EXIT - X SET /P SRH=0   IF %SRH%==1 GOTO SHUTDOWNM IF %SRH%==2 GOTO RESTARTM IF %SRH%==3 GOTO HIBERNATEM IF %SRH%==M GOTO MENUIF %SRH%==X GOTO EXIT 

Up to this point it's been just menus and command line navigation. Now we start actually doing things. The way the SRH menu works is pretty simple. After selecting your desired operation you're prompted to input the delay time in seconds before your selected action takes place. This is the most basic form you can do it and still have an idea how long it will take until it happens. There is an alternative to this, but it doesn't show you exactly how much time is left.

 

Shutdown

:SHUTDOWNM CLS ECHO. ECHO INPUT TIME TO SHUTDOWN IN SECONDS AND PRESS ENTERECHO 1M = 60 ECHO 5M = 300 ECHO 10M = 600 ECHO 15M = 900 ECHO 30M = 1800 ECHO 1H = 3600 ECHO PREVIOUS - PECHO MAIN MENU - MM SET /P S=TIME  IF %S%==P GOTO SRHIF %S%==MM GOTO MENU  TIMEOUT /T %S% /NOBREAK & SHUTDOWN /H

Restart

:RESTARTM CLS ECHO. ECHO INPUT TIME TO RESTART IN SECONDS AND PRESS ENTERECHO 1M = 60 ECHO 5M = 300 ECHO 10M = 600 ECHO 15M = 900 ECHO 30M = 1800 ECHO 1H = 3600 ECHO PREVIOUS - PECHO MAIN MENU - MM SET /P R=TIME IF %R%==P GOTO SRHIF %R%==MM GOTO MENU TIMEOUT /T %R% /NOBREAK & SHUTDOWN /R

Hibernate

:HIBERNATEM CLS ECHO. ECHO INPUT TIME TO HIBERNATE IN SECONDS ECHO 1M = 60 ECHO 5M = 300 ECHO 10M = 600 ECHO 15M = 900 ECHO 30M = 1800 ECHO 1H = 3600 ECHO PREVIOUS - PECHO MAIN MENU - MM SET /P H=TIME IF %H%==P GOTO SRHIF %H%==MM GOTO MENU  TIMEOUT /T %H% /NOBREAK & SHUTDOWN /H

Part 3: Network

Some network-related commands using ipconfig

:NETWORKCLSECHO.ECHO 2.1 - Display full configuration informationECHO 2.2 - Release IPv4 and IPv6 address for the current adapterECHO 2.3 - Renew the IPv4 and IPv6 address for the current adapterECHO 2.4 - Purge the DNS Resolver cacheECHO 2.5 - Refresh all the DHCP leases and re-register DNS namesECHO MM - Return to the main menuSET /P N=NETWORKIF %N%==2.1 GOTO CONFIGIF %N%==2.2 GOTO RELEASEIF %N%==2.3 GOTO RENEWIF %N%==2.4 GOTO FLUSHIF %N%==2.5 GOTO REFRESHDNSIF %N%==MM GOTO MENU:CONFIG:: Display full configuration informationipconfig /allECHO.EcHO Input P and press Enter to go to the previous menuSET /P P=PREVIOUSIF %P%==P GOTO NETWORK:RELEASE:: Release IPv4 and IPv6 address for the current adapteripconfig /release & ipconfig /release6GOTO NETWORK:RENEW:: Renew the IPv4 and IPv6 address for the current adapteripconfig /renew & ipconfig /renew6GOTO NETWORK:FLUSH:: Purge the DNS Resolver cacheipconfig /flushdnsGOTO NETWORK:REFRESHDNS:: Refresh all the DHCP leases and re-register DNS namesipconfig /registerdnsGOTO NETWORK

This is a WORK IN PROGRESS and should be treated as such.

This was made for personal use and I am sharing it in case anyone else is interested in it.

  • Find a way to give the ability to cancel shutdown/reboot/hibernate and keep the timeout countdown. Ctrl+C just skips the timer and jumps to the next command.
  • Create AdHoc WiFi Network
  • Network Adapter common commands (ipconfig, etc.) Partially implemented, not tested for proper operation
  • Memory flush

08/10/15 - v0.01

  • created menu
  • created SRH menu and implemented the shutdown, restart and hibernate functions

09/10/15 - v0.02

  • created Network menu and implemented ipconfig commands: display, release, renew, DNS flush and DNS refresh for both IPv4 and IPv6 (where applicable)
  • added versions. Revisions will be used when no major features are added or when re-working existing features

Remember kids, the only difference between screwing around and science is writing it down. - Adam Savage

 

PHOΞNIX Ryzen 5 1600 @ 3.75GHz | Corsair LPX 16Gb DDR4 @ 2933 | MSI B350 Tomahawk | Sapphire RX 480 Nitro+ 8Gb | Intel 535 120Gb | Western Digital WD5000AAKS x2 | Cooler Master HAF XB Evo | Corsair H80 + Corsair SP120 | Cooler Master 120mm AF | Corsair SP120 | Icy Box IB-172SK-B | OCZ CX500W | Acer GF246 24" + AOC <some model> 21.5" | Steelseries Apex 350 | Steelseries Diablo 3 | Steelseries Syberia RAW Prism | Corsair HS-1 | Akai AM-A1

D.VA coming soon™ xoxo

Sapphire Acer Aspire 1410 Celeron 743 | 3Gb DDR2-667 | 120Gb HDD | Windows 10 Home x32

Vault Tec Celeron 420 | 2Gb DDR2-667 | Storage pending | Open Media Vault

gh0st Asus K50IJ T3100 | 2Gb DDR2-667 | 40Gb HDD | Ubuntu 17.04

Diskord Apple MacBook A1181 Mid-2007 Core2Duo T7400 @2.16GHz | 4Gb DDR2-667 | 120Gb HDD | Windows 10 Pro x32

Firebird//Phoeniix FX-4320 | Gigabyte 990X-Gaming SLI | Asus GTS 450 | 16Gb DDR3-1600 | 2x Intel 535 250Gb | 4x 10Tb Western Digital Red | 600W Segotep custom refurb unit | Windows 10 Pro x64 // offisite backup and dad's PC

 

Saint Olms Apple iPhone 6 16Gb Gold

Archon Microsoft Lumia 640 LTE

Gulliver Nokia Lumia 1320

Werkfern Nokia Lumia 520

Hydromancer Acer Liquid Z220

Link to comment
Share on other sites

Link to post
Share on other sites

Wait... You use the command line to shut down?

Thats that. If you need to get in touch chances are you can find someone that knows me that can get in touch.

Link to comment
Share on other sites

Link to post
Share on other sites

For ages I've been using the command line in Windows to do stuff faster/easier or just for stuff that can't be done otherwise without downloading some shady piece of (possibly) malware-ridden software from an equally 

I gotta say, thats pretty cool !

 

 

 

but why ?

~New~  BoomBerryPi project !  ~New~


new build log : http://linustechtips.com/main/topic/533392-build-log-the-scrap-simulator-x/?p=7078757 (5 screen flight sim for 620$ CAD)LTT Web Challenge is back ! go here  :  http://linustechtips.com/main/topic/448184-ltt-web-challenge-3-v21/#entry601004

Link to comment
Share on other sites

Link to post
Share on other sites

Wait... You use the command line to shut down?

Technically I never shut down my PC.

At first I started using the hibernate timeout part just so my PC would enter hibernation after I fell asleep. I wanted the timeout counter so I could see how much time was left in case I couldn't sleep/etc. Figured I could throw in the shutdown and reboot commands aswell. It's just copy/pasta and changing a couple of attributes

I gotta say, thats pretty cool !

 

 

 

but why ?

 

I'm an oldschool console freak and I prefer doing certain tasks in a command line rather than navigate through the UI to get to something I could do in 5 seconds in the console

Remember kids, the only difference between screwing around and science is writing it down. - Adam Savage

 

PHOΞNIX Ryzen 5 1600 @ 3.75GHz | Corsair LPX 16Gb DDR4 @ 2933 | MSI B350 Tomahawk | Sapphire RX 480 Nitro+ 8Gb | Intel 535 120Gb | Western Digital WD5000AAKS x2 | Cooler Master HAF XB Evo | Corsair H80 + Corsair SP120 | Cooler Master 120mm AF | Corsair SP120 | Icy Box IB-172SK-B | OCZ CX500W | Acer GF246 24" + AOC <some model> 21.5" | Steelseries Apex 350 | Steelseries Diablo 3 | Steelseries Syberia RAW Prism | Corsair HS-1 | Akai AM-A1

D.VA coming soon™ xoxo

Sapphire Acer Aspire 1410 Celeron 743 | 3Gb DDR2-667 | 120Gb HDD | Windows 10 Home x32

Vault Tec Celeron 420 | 2Gb DDR2-667 | Storage pending | Open Media Vault

gh0st Asus K50IJ T3100 | 2Gb DDR2-667 | 40Gb HDD | Ubuntu 17.04

Diskord Apple MacBook A1181 Mid-2007 Core2Duo T7400 @2.16GHz | 4Gb DDR2-667 | 120Gb HDD | Windows 10 Pro x32

Firebird//Phoeniix FX-4320 | Gigabyte 990X-Gaming SLI | Asus GTS 450 | 16Gb DDR3-1600 | 2x Intel 535 250Gb | 4x 10Tb Western Digital Red | 600W Segotep custom refurb unit | Windows 10 Pro x64 // offisite backup and dad's PC

 

Saint Olms Apple iPhone 6 16Gb Gold

Archon Microsoft Lumia 640 LTE

Gulliver Nokia Lumia 1320

Werkfern Nokia Lumia 520

Hydromancer Acer Liquid Z220

Link to comment
Share on other sites

Link to post
Share on other sites

Nice little project to get familiar with batch I suppose, but as it stands and with the features you'd like to add eventually its functionality isn't very useful.

Link to comment
Share on other sites

Link to post
Share on other sites

Nice little project to get familiar with batch I suppose, but as it stands and with the features you'd like to add eventually its functionality isn't very useful.

 

What's in it is pretty much what I managed to fit into a coffee break's worth of writing at work. I'll be adding more to it soon

Remember kids, the only difference between screwing around and science is writing it down. - Adam Savage

 

PHOΞNIX Ryzen 5 1600 @ 3.75GHz | Corsair LPX 16Gb DDR4 @ 2933 | MSI B350 Tomahawk | Sapphire RX 480 Nitro+ 8Gb | Intel 535 120Gb | Western Digital WD5000AAKS x2 | Cooler Master HAF XB Evo | Corsair H80 + Corsair SP120 | Cooler Master 120mm AF | Corsair SP120 | Icy Box IB-172SK-B | OCZ CX500W | Acer GF246 24" + AOC <some model> 21.5" | Steelseries Apex 350 | Steelseries Diablo 3 | Steelseries Syberia RAW Prism | Corsair HS-1 | Akai AM-A1

D.VA coming soon™ xoxo

Sapphire Acer Aspire 1410 Celeron 743 | 3Gb DDR2-667 | 120Gb HDD | Windows 10 Home x32

Vault Tec Celeron 420 | 2Gb DDR2-667 | Storage pending | Open Media Vault

gh0st Asus K50IJ T3100 | 2Gb DDR2-667 | 40Gb HDD | Ubuntu 17.04

Diskord Apple MacBook A1181 Mid-2007 Core2Duo T7400 @2.16GHz | 4Gb DDR2-667 | 120Gb HDD | Windows 10 Pro x32

Firebird//Phoeniix FX-4320 | Gigabyte 990X-Gaming SLI | Asus GTS 450 | 16Gb DDR3-1600 | 2x Intel 535 250Gb | 4x 10Tb Western Digital Red | 600W Segotep custom refurb unit | Windows 10 Pro x64 // offisite backup and dad's PC

 

Saint Olms Apple iPhone 6 16Gb Gold

Archon Microsoft Lumia 640 LTE

Gulliver Nokia Lumia 1320

Werkfern Nokia Lumia 520

Hydromancer Acer Liquid Z220

Link to comment
Share on other sites

Link to post
Share on other sites

Added some network commands using ipconfig and I am now using versions when adding new components (I'll call them modules from now on) and revisions when refining how previously added modules work

Remember kids, the only difference between screwing around and science is writing it down. - Adam Savage

 

PHOΞNIX Ryzen 5 1600 @ 3.75GHz | Corsair LPX 16Gb DDR4 @ 2933 | MSI B350 Tomahawk | Sapphire RX 480 Nitro+ 8Gb | Intel 535 120Gb | Western Digital WD5000AAKS x2 | Cooler Master HAF XB Evo | Corsair H80 + Corsair SP120 | Cooler Master 120mm AF | Corsair SP120 | Icy Box IB-172SK-B | OCZ CX500W | Acer GF246 24" + AOC <some model> 21.5" | Steelseries Apex 350 | Steelseries Diablo 3 | Steelseries Syberia RAW Prism | Corsair HS-1 | Akai AM-A1

D.VA coming soon™ xoxo

Sapphire Acer Aspire 1410 Celeron 743 | 3Gb DDR2-667 | 120Gb HDD | Windows 10 Home x32

Vault Tec Celeron 420 | 2Gb DDR2-667 | Storage pending | Open Media Vault

gh0st Asus K50IJ T3100 | 2Gb DDR2-667 | 40Gb HDD | Ubuntu 17.04

Diskord Apple MacBook A1181 Mid-2007 Core2Duo T7400 @2.16GHz | 4Gb DDR2-667 | 120Gb HDD | Windows 10 Pro x32

Firebird//Phoeniix FX-4320 | Gigabyte 990X-Gaming SLI | Asus GTS 450 | 16Gb DDR3-1600 | 2x Intel 535 250Gb | 4x 10Tb Western Digital Red | 600W Segotep custom refurb unit | Windows 10 Pro x64 // offisite backup and dad's PC

 

Saint Olms Apple iPhone 6 16Gb Gold

Archon Microsoft Lumia 640 LTE

Gulliver Nokia Lumia 1320

Werkfern Nokia Lumia 520

Hydromancer Acer Liquid Z220

Link to comment
Share on other sites

Link to post
Share on other sites

  • 2 weeks later...

Been using it for a couple weeks now and I must say it's buggy AF. Need to implement returns for recurring usage and clean up the inputs. new revision soon. ish.

Remember kids, the only difference between screwing around and science is writing it down. - Adam Savage

 

PHOΞNIX Ryzen 5 1600 @ 3.75GHz | Corsair LPX 16Gb DDR4 @ 2933 | MSI B350 Tomahawk | Sapphire RX 480 Nitro+ 8Gb | Intel 535 120Gb | Western Digital WD5000AAKS x2 | Cooler Master HAF XB Evo | Corsair H80 + Corsair SP120 | Cooler Master 120mm AF | Corsair SP120 | Icy Box IB-172SK-B | OCZ CX500W | Acer GF246 24" + AOC <some model> 21.5" | Steelseries Apex 350 | Steelseries Diablo 3 | Steelseries Syberia RAW Prism | Corsair HS-1 | Akai AM-A1

D.VA coming soon™ xoxo

Sapphire Acer Aspire 1410 Celeron 743 | 3Gb DDR2-667 | 120Gb HDD | Windows 10 Home x32

Vault Tec Celeron 420 | 2Gb DDR2-667 | Storage pending | Open Media Vault

gh0st Asus K50IJ T3100 | 2Gb DDR2-667 | 40Gb HDD | Ubuntu 17.04

Diskord Apple MacBook A1181 Mid-2007 Core2Duo T7400 @2.16GHz | 4Gb DDR2-667 | 120Gb HDD | Windows 10 Pro x32

Firebird//Phoeniix FX-4320 | Gigabyte 990X-Gaming SLI | Asus GTS 450 | 16Gb DDR3-1600 | 2x Intel 535 250Gb | 4x 10Tb Western Digital Red | 600W Segotep custom refurb unit | Windows 10 Pro x64 // offisite backup and dad's PC

 

Saint Olms Apple iPhone 6 16Gb Gold

Archon Microsoft Lumia 640 LTE

Gulliver Nokia Lumia 1320

Werkfern Nokia Lumia 520

Hydromancer Acer Liquid Z220

Link to comment
Share on other sites

Link to post
Share on other sites

Why not use PowerShell to do all this? Batch files are good and all, but let face it, they are not going to be used for very much longer, same as VB scripts, they are just not very powerful. And most admins are moving away from them.

Link to comment
Share on other sites

Link to post
Share on other sites

Why not use PowerShell to do all this? Batch files are good and all, but let face it, they are not going to be used for very much longer, same as VB scripts, they are just not very powerful. And most admins are moving away from them.

Somehow the geniuses at work disabled PowerShell because reasons. Might make a second version that uses PowerShell, but as it stands I'll stick to command line. Plus, it works on pretty much any Windows like this (although I don't see myself using XP anytime in the next millennium)

Remember kids, the only difference between screwing around and science is writing it down. - Adam Savage

 

PHOΞNIX Ryzen 5 1600 @ 3.75GHz | Corsair LPX 16Gb DDR4 @ 2933 | MSI B350 Tomahawk | Sapphire RX 480 Nitro+ 8Gb | Intel 535 120Gb | Western Digital WD5000AAKS x2 | Cooler Master HAF XB Evo | Corsair H80 + Corsair SP120 | Cooler Master 120mm AF | Corsair SP120 | Icy Box IB-172SK-B | OCZ CX500W | Acer GF246 24" + AOC <some model> 21.5" | Steelseries Apex 350 | Steelseries Diablo 3 | Steelseries Syberia RAW Prism | Corsair HS-1 | Akai AM-A1

D.VA coming soon™ xoxo

Sapphire Acer Aspire 1410 Celeron 743 | 3Gb DDR2-667 | 120Gb HDD | Windows 10 Home x32

Vault Tec Celeron 420 | 2Gb DDR2-667 | Storage pending | Open Media Vault

gh0st Asus K50IJ T3100 | 2Gb DDR2-667 | 40Gb HDD | Ubuntu 17.04

Diskord Apple MacBook A1181 Mid-2007 Core2Duo T7400 @2.16GHz | 4Gb DDR2-667 | 120Gb HDD | Windows 10 Pro x32

Firebird//Phoeniix FX-4320 | Gigabyte 990X-Gaming SLI | Asus GTS 450 | 16Gb DDR3-1600 | 2x Intel 535 250Gb | 4x 10Tb Western Digital Red | 600W Segotep custom refurb unit | Windows 10 Pro x64 // offisite backup and dad's PC

 

Saint Olms Apple iPhone 6 16Gb Gold

Archon Microsoft Lumia 640 LTE

Gulliver Nokia Lumia 1320

Werkfern Nokia Lumia 520

Hydromancer Acer Liquid Z220

Link to comment
Share on other sites

Link to post
Share on other sites

Being a linux user I get where you are coming from, OP. Although I am not fluent in BATCH beyond the basic commands that work with dosbox, I am very fluent with BASH and I absolutely love it.

 

Never thought to do an all-in-one script thought, I've only made small scripts that clutter my home folder.

I should say though, it might be a good idea to learn how to add comments. I know there is a way but I don't remember how

My procrastination is the bane of my existence.

I make games and stuff in my spare time.

 

 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×