Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Batch file with options, is there any way to clean this up or shorten?

19 Jun 2017   #1
PressAltandF4

Windows 10 Professional x64
 
 
Batch file with options, is there any way to clean this up or shorten?

So I'm trying to create a batch file to reboot a computer I choose based off of IP using PSexec.

I have it, it's working but I'm wondering if there is a simpler way of writing this batch file. Here is what I have.

Code:
 @echo
cls

set "PASS=password"
set "USER=admin"

:Start
echo 25.
echo 1.
echo 2.
echo 3.
echo 12.
echo 13.
echo 14.
echo 15.
echo 26.
echo 31.
echo 32.
echo 33.
echo 34.
echo 35.
echo 36.
echo 81. 
set /p choice=Enter Device Number.

if '%choice%'=='25' goto :25
if '%choice%'=='1' goto :1
if '%choice%'=='2' goto :2
if '%choice%'=='3' goto :3
if '%choice%'=='12' goto :12
if '%choice%'=='13' goto :13
if '%choice%'=='14' goto :14
if '%choice%'=='15' goto :15
if '%choice%'=='26' goto :26
if '%choice%'=='31' goto :31
if '%choice%'=='32' goto :32
if '%choice%'=='33' goto :33
if '%choice%'=='34' goto :34
if '%choice%'=='35' goto :35
if '%choice%'=='36' goto :36
if '%choice%'=='81' goto :81
echo "%choice%" is not a valid option. Please try again.
echo.
goto start
:25
psexec \\10.0.0.25 -u %USER% -p %PASS% shutdown -r
goto end
:1
psexec \\10.0.0.1 -u %USER% -p %PASS% shutdown -r
goto end
:2
psexec \\10.0.0.2 -u %USER% -p %PASS% shutdown -r
goto end
:3
psexec \\10.0.0.3 -u %USER% -p %PASS% shutdown -r
goto end
:12
psexec \\10.0.0.12 -u %USER% -p %PASS% shutdown -r
goto end
:13
psexec \\10.0.0.13 -u %USER% -p %PASS% shutdown -r
goto end
:14
psexec \\10.0.0.14 -u %USER% -p %PASS% shutdown -r
goto end
:15
psexec \\10.0.0.15 -u %USER% -p %PASS% shutdown -r
goto end
:26
psexec \\10.0.0.26 -u %USER% -p %PASS% shutdown -r
goto end
:31
psexec \\10.0.0.31 -u %USER% -p %PASS% shutdown -r
goto end
:32
psexec \\10.0.0.32 -u %USER% -p %PASS% shutdown -r
goto end
:33
psexec \\10.0.0.33 -u %USER% -p %PASS% shutdown -r
goto end
:34
psexec \\10.0.0.34 -u %USER% -p %PASS% shutdown -r
goto end
:35
psexec \\10.0.0.35 -u %USER% -p %PASS% shutdown -r
goto end
:36
psexec \\10.0.0.36 -u %USER% -p %PASS% shutdown -r
goto end
:81
psexec \\10.0.0.81 -u %USER% -p %PASS% shutdown -r
goto end
:end
pause



My System SpecsSystem Spec
.
19 Jun 2017   #2
PressAltandF4

Windows 10 Professional x64
 
 

Nevermind, I figured out another way that's way less complicated.

Code:
 @echo off
cls

set "PASS=password"
set "USER=admin"

set /p DEV=Enter Device Number = 

psexec \\10.0.0.%DEV% -u %USER% -p %PASS% shutdown -r

pause
My System SpecsSystem Spec
Reply

 Batch file with options, is there any way to clean this up or shorten?




Thread Tools




Similar help and support threads
Thread Forum
Batch File .bat to copy file from File Sharing & FTP Hosting
Hi all, Any idea how to write Batch File .bat to copy file from File Sharing & FTP Hosting to local directory. Current the File Sharing & FTP Hosting is SMARTFILE. I don't want to use WINSCP as the connector. Thanks
General Discussion
How to run a batch file at logoff & some batch scripting help please
Hiya, I'd just like to run a simple batch file at logoff to backup some settings. I plan to use Robocopy, which is what i use to more thorough backups. Two questions: 1. How make it run by clicking Start > Shutdown? (i realise i could make a shutdown batch file and run it instead, but i'd...
Backup and Restore
Shorten file/folder highlight area?
Hi, I would like to know if there is any way to shorten file/folder selection area, as it was in WinXP. Example: http://i692.photobucket.com/albums/vv285/Xenon_bioware/feature.jpg Please, no replies like "This is by (idiotic) design". That is obvious, I need a way to fix it. If I select a folder,...
General Discussion
Batch File that grabs file names from folder to insert into batch file
Ok I'm totally at a loss on how to word this so I'm just going to write it out the best that I can... :confused: First I have a batch file that I'm writing that will convert mp4 files to mp3 files (I have a lot) for a buddies band using ffmpeg. Here's the code that I'm using: ffmpeg -i...
General Discussion
Shorten wav file
I have a 10 second wav file. How can I shorten it ti 2 seconds?
Music, Pictures & Video


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 15:27.
Twitter Facebook Google+ Seven Forums iOS App Seven Forums Android App