using InteractiveUtils
println("1. Shutdown Computer Now")
println("2. Shutdown Computer after t seconds")
println("3. Restart Computer Now")
println("4. Restart Computer after t seconds")
println("5. Exit from program")
println("Enter Your Choice: ")
choice = parse(Int, readline())
if choice == 1
run(`shutdown /s /t 0`)
elseif choice == 2
println("Enter Number of Seconds: ")
sec = parse(Int, readline())
run(`shutdown /s /t $sec`)
elseif choice == 3
run(`shutdown /r /t 0`)
elseif choice == 4
println("Enter Number of Seconds: ")
sec = parse(Int, readline())
run(`shutdown /r /t $sec`)
elseif choice == 5
exit()
else
println("Wrong Choice!")
end
In this code the line using InteractiveUtils
is importing utilities to interact with the operating system.
Please note that executing commands to shutdown or restart a computer may require administrative privileges. Additionally, make sure you have the necessary permissions to execute such commands on your system.
Top comments (3)
InteractiveUtils seems to be not needed in this script. It works without
using InteractiveUtils
.Does this works on Windows???
Yes