Script To Shut Down My Pc

 
#1

Hello forum..!

May i ask if it is possible to create a Script that can shut down my PC when the voltage goes less than 4,5V?


*confused*

#2

The following script command will immediately shutdown the computer, forcing the shutdown even if there are running applications or other logged on users:

Code:


exec("shutdown.exe", "/p /f")



replace the /p with /s if you want 1 minute of warning, and if you want to abort the shutdown during the warning period, open a command prompt and type

Code:


shutdown /a



Keep in mind that any unsaved work will be lost, so use with caution. If you want to be sure not to lose any work, instead of /s or /p you can use /h and it will hibernate the computer instead of shutting it down.

Alan

#3

Here's to expand on alan's command. Create an EZ-Script control that will run and check in a loop...

Code:


:loop

# if voltage is less than 4.5 and the ez-b is connected
IF (getVoltage() < 4.5 and isConnected(0))

say("Shutting computer down in one minute")

exec("shutdown.exe", "/s /f")

ENDIF

# check every minute
sleep(60 * 1000)

goto(loop)



Have the ez-script control automatically start when the ez-b is connected in the SETTINGS menu of the connection control. Assuming your named your script "POWER CHECK"

Code:


ControlCommand("Power Check", ScriptStart)

#4

Good Morning & thanks for the reply Alan and DJ SuresSmile

i forgot to write that i use the EZ-B V3 Controller!

it is very helpful for my project.

i am going to test it !

#5

the v3 controller will not work with GetVoltage().

You will have to connect the +5 on the ADC port and use GetADC() instead. Simply add a jumper on ADC0 between the +5 and Signal

#6

ok Dj .. and code still the same.

thanks again.

#7

No, the code would have to change from using getvoltage to adc. Because there is no voltage monitor on the v3. You can rig one of the adc ports to the +5 using a jumper to get the voltage.

#8

@sakis33 do you want to monitor your "PC's" voltage or the robot's voltage on the EZB? I think the examples provide so far are how to monitor and react to if the EZB voltage is low.

#9

Hello again Dj,

something like that code:

:loop



if (GetADC( adc0 ) <4.5 and IsConnected( 0 ) )

Say(" shutting computer in one minute " )

Exec( "shutdown.exe", "/s/f" )

EndIf




Sleep(60*1000 )

Goto (loop)

#10

Hi justin..,

as i write i want to create a Script that can shut down my PC when the voltage goes less than 4,5V?

i use V3 controller with a pc board. i want to know robot's voltage .