Jump to content

Batch not working

MrMcMuffinJr
echo Deletion of temporary files is complete, but it is required that you restart your computer. Would you like to restart now?[Y/N]
choice /c YN
if %errorlevel%== Y goto Shutdown
if %errorlevel%== N goto NoThanks

:Shutdown

shutdown -r -t 999
exit

:NoThanks
exit

It initiates restart no matter the choice. any idea why?

Favorite Threads: PSU Tier List

 

My Stuff n' Things

Spoiler

The Beast (My Rig)   |CPU: AMD Ryzen 9 3900X|  |Cooling: Enermax Liquimax III, 6x 120mm Noctua Redux|  |Motherboard:  MSI MPG B550 Gaming Plus|  |RAM: 4x32gb 3200 G.Skill TridentZ NEO|  |Graphics Card: EVGA(RIP) GeForce RTX 3070TI FTW3|  |Power Supply: Corsair CX-M 750W|  |Case: Corsair 4000D Airflow Mid Tower Case(Black)|  |SSD: 1Tb WD BLACK NVMe, 500gb NVMe, 1Tb Samsung 850 EVO|  |Monitor: MSI Optix MPG341QR 34" Ultrawide|  |Keyboard: Logitech G815|  |Mouse: Logitech G203 LIGHTSYNC|  |Audio Interface: FiiO K7 DAC/Amp|  |Headphones: Sennheiser HD6XX |Webcam: Logitech C920, Logitech C270|

 

My Network Rack  |Switch: Cisco Dell PowerConnect 5548P|  |Router: Unifi USG|  |Rack: 12U|  |Server: HP Z420|  |Services: Proxmox PVE, Wireguard, Pihole, NVR, NAS|

 

Link to comment
Share on other sites

Link to post
Share on other sites

I would suggest that you remove the empty line after :Shutdown ;)

Link to comment
Share on other sites

Link to post
Share on other sites

4 minutes ago, Braxlaw said:

I would suggest that you remove the empty line after :Shutdown ;)

same thing

Favorite Threads: PSU Tier List

 

My Stuff n' Things

Spoiler

The Beast (My Rig)   |CPU: AMD Ryzen 9 3900X|  |Cooling: Enermax Liquimax III, 6x 120mm Noctua Redux|  |Motherboard:  MSI MPG B550 Gaming Plus|  |RAM: 4x32gb 3200 G.Skill TridentZ NEO|  |Graphics Card: EVGA(RIP) GeForce RTX 3070TI FTW3|  |Power Supply: Corsair CX-M 750W|  |Case: Corsair 4000D Airflow Mid Tower Case(Black)|  |SSD: 1Tb WD BLACK NVMe, 500gb NVMe, 1Tb Samsung 850 EVO|  |Monitor: MSI Optix MPG341QR 34" Ultrawide|  |Keyboard: Logitech G815|  |Mouse: Logitech G203 LIGHTSYNC|  |Audio Interface: FiiO K7 DAC/Amp|  |Headphones: Sennheiser HD6XX |Webcam: Logitech C920, Logitech C270|

 

My Network Rack  |Switch: Cisco Dell PowerConnect 5548P|  |Router: Unifi USG|  |Rack: 12U|  |Server: HP Z420|  |Services: Proxmox PVE, Wireguard, Pihole, NVR, NAS|

 

Link to comment
Share on other sites

Link to post
Share on other sites

@echo off
echo Are You Sure?[Y/N]
choice /c YN
if %errorlevel%== Y goto Tempdel
if %errorlevel%== N exit

:Tempdel
del /q/f/s %TEMP%\*

cls

echo Deletion of temporary files is complete, but it is required that you restart your computer. Would you like to restart now?[Y/N]
choice /c YN
if %errorlevel%== Y goto Shutdown
if %errorlevel%== N goto NoThanks

:Shutdown
shutdown -r -t 999
exit

:NoThanks
exit

exit

this is the whole thing

Favorite Threads: PSU Tier List

 

My Stuff n' Things

Spoiler

The Beast (My Rig)   |CPU: AMD Ryzen 9 3900X|  |Cooling: Enermax Liquimax III, 6x 120mm Noctua Redux|  |Motherboard:  MSI MPG B550 Gaming Plus|  |RAM: 4x32gb 3200 G.Skill TridentZ NEO|  |Graphics Card: EVGA(RIP) GeForce RTX 3070TI FTW3|  |Power Supply: Corsair CX-M 750W|  |Case: Corsair 4000D Airflow Mid Tower Case(Black)|  |SSD: 1Tb WD BLACK NVMe, 500gb NVMe, 1Tb Samsung 850 EVO|  |Monitor: MSI Optix MPG341QR 34" Ultrawide|  |Keyboard: Logitech G815|  |Mouse: Logitech G203 LIGHTSYNC|  |Audio Interface: FiiO K7 DAC/Amp|  |Headphones: Sennheiser HD6XX |Webcam: Logitech C920, Logitech C270|

 

My Network Rack  |Switch: Cisco Dell PowerConnect 5548P|  |Router: Unifi USG|  |Rack: 12U|  |Server: HP Z420|  |Services: Proxmox PVE, Wireguard, Pihole, NVR, NAS|

 

Link to comment
Share on other sites

Link to post
Share on other sites

Ah and you need to change y/n to 1/2 in your if query.

Quote

The ERRORLEVEL is set to the offset of the index of the key that was selected from the set of choices.
The first choice listed returns a value of 1, the second a value of 2, and so on.

 

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, Braxlaw said:

Ah and you need to change y/n to 1/2 in your if query.

 

so what should the new code be? my batch knowledge is all google lol

Favorite Threads: PSU Tier List

 

My Stuff n' Things

Spoiler

The Beast (My Rig)   |CPU: AMD Ryzen 9 3900X|  |Cooling: Enermax Liquimax III, 6x 120mm Noctua Redux|  |Motherboard:  MSI MPG B550 Gaming Plus|  |RAM: 4x32gb 3200 G.Skill TridentZ NEO|  |Graphics Card: EVGA(RIP) GeForce RTX 3070TI FTW3|  |Power Supply: Corsair CX-M 750W|  |Case: Corsair 4000D Airflow Mid Tower Case(Black)|  |SSD: 1Tb WD BLACK NVMe, 500gb NVMe, 1Tb Samsung 850 EVO|  |Monitor: MSI Optix MPG341QR 34" Ultrawide|  |Keyboard: Logitech G815|  |Mouse: Logitech G203 LIGHTSYNC|  |Audio Interface: FiiO K7 DAC/Amp|  |Headphones: Sennheiser HD6XX |Webcam: Logitech C920, Logitech C270|

 

My Network Rack  |Switch: Cisco Dell PowerConnect 5548P|  |Router: Unifi USG|  |Rack: 12U|  |Server: HP Z420|  |Services: Proxmox PVE, Wireguard, Pihole, NVR, NAS|

 

Link to comment
Share on other sites

Link to post
Share on other sites

4 minutes ago, MrMcMuffinJr said:

if %errorlevel%== Y goto Shutdown if %errorlevel%== N goto NoThanks

4 minutes ago, MrMcMuffinJr said:

if %errorlevel%== 1 goto Shutdown if %errorlevel%== 2 goto NoThanks

Link to comment
Share on other sites

Link to post
Share on other sites

3 minutes ago, Braxlaw said:

 

THAT DID IT THANKS!!!!!

 

Favorite Threads: PSU Tier List

 

My Stuff n' Things

Spoiler

The Beast (My Rig)   |CPU: AMD Ryzen 9 3900X|  |Cooling: Enermax Liquimax III, 6x 120mm Noctua Redux|  |Motherboard:  MSI MPG B550 Gaming Plus|  |RAM: 4x32gb 3200 G.Skill TridentZ NEO|  |Graphics Card: EVGA(RIP) GeForce RTX 3070TI FTW3|  |Power Supply: Corsair CX-M 750W|  |Case: Corsair 4000D Airflow Mid Tower Case(Black)|  |SSD: 1Tb WD BLACK NVMe, 500gb NVMe, 1Tb Samsung 850 EVO|  |Monitor: MSI Optix MPG341QR 34" Ultrawide|  |Keyboard: Logitech G815|  |Mouse: Logitech G203 LIGHTSYNC|  |Audio Interface: FiiO K7 DAC/Amp|  |Headphones: Sennheiser HD6XX |Webcam: Logitech C920, Logitech C270|

 

My Network Rack  |Switch: Cisco Dell PowerConnect 5548P|  |Router: Unifi USG|  |Rack: 12U|  |Server: HP Z420|  |Services: Proxmox PVE, Wireguard, Pihole, NVR, NAS|

 

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

×