View Full Version : making a script call a separate script or shut-down the pc
BazzBarrett
04-27-2011, 10:33 PM
basicly i want the script to shut down my computer after its done. i was thinking if i could call another script i could have it just press the shut down button. or could i make the script call a .bat file? or access any of the windows Librarys to call a shut down command? any suggestions would be appreciated.
HarryJames
04-27-2011, 11:06 PM
I've searched for functions, but nope :(
Unless you were able to create your own Dialog Box, and then make that launch the script (if simba supports ARGs!).
superuser
04-27-2011, 11:23 PM
Umm,
Open command prompt and let SIMBA type
shutdown -s
Shady?
04-27-2011, 11:27 PM
I think you should call a bat file with the shutdown code, something around this lines:
echo shutdown -s -t 1
where 1 is the ammount of seconds before shutdown.
HarryJames
04-27-2011, 11:29 PM
That wouldn't work if he wants it to have his PC shut down after the character(s) is/are finnished etc.
I'd want to do the same if I was going on holiday for XYZ amount of time.
superuser
04-27-2011, 11:30 PM
I think you should call a bat file with the shutdown code, something around this lines:
echo shutdown -s -t 1
where 1 is the ammount of seconds before shutdown.
Won't work, since you got echo there.
superuser
04-27-2011, 11:33 PM
That wouldn't work if he wants it to have his PC shut down after the character(s) is/are finnished etc.
I'd want to do the same if I was going on holiday for XYZ amount of time.
Well, the solution to that couldn't be more simple. Just have two instances of SIMBA running. Other writes for example .ini file with the status of the script while other reads it. When the other script gets go ahead, it shuts down the unit.
EDIT:
Lol, even more simple and more elegant is Shady?'s answer below :)
Shady?
04-27-2011, 11:33 PM
That wouldn't work if he wants it to have his PC shut down after the character(s) is/are finnished etc.
I'd want to do the same if I was going on holiday for XYZ amount of time.
He could call the shutdown function whenever he wants, maybe add it to TerminateScript/ScriptTerminate (havn't scripted for a while, sorry :P) or just have the script to check if all the players are inactive/finished, and then call the function ?
BazzBarrett
04-27-2011, 11:34 PM
simba cant call .bat files anyway. well not without alot of work. ive done it now :) i just had the script create a file called sd.txt and insert the letter F (for false) then change that to T when the script ends. i then run another script which checks the file and when it is done it simply clicks start then shutdown. simples.
EDIT: @superuser lol great minds think alike.
anonymity
04-27-2011, 11:42 PM
I don't remember where I found this but, this works:
Procedure ShutDownPC;
begin
if (ShutDownYourPC = False) then
TerminateScript;
if ShutDownYourPC then
begin
WriteLn('');
WriteLn('Time to GTFO!!');
WriteLn('You have 60 seconds to panic and start\run: "shutdown -a"');
KeyDown(92);
Wait(200);
KeyDown(82);
Wait(200);
KeyUp(82);
Wait(200);
KeyUp(92);
Wait(2000);
SendKeys('shutdown -s -f -t 80 -c "OMG Rebooting!!"');
//Wait(20000);
KeyDown(13);
Wait(200);
KeyUp(13);
Wait(1600000);
//SaveDebug;
TerminateScript;
end;
end;
For simba.. you just need to change the SendKeys(); to something else, because sendkeys doesn't work right.
Shady?
04-27-2011, 11:55 PM
Okay, I got it :)
Make a bat called sd.bat, place it anywhere (i'd say c:\sd.bat), with this inside:
@echo off
shutdown -s -t 1 -c "shutting down"
Now, in simba call this to shut down the pc:
OpenWebPage('c:\sd.bat');
Probably not the best way, but it works :P
BazzBarrett
04-28-2011, 03:20 PM
Okay, I got it :)
Make a bat called sd.bat, place it anywhere (i'd say c:\sd.bat), with this inside:
@echo off
shutdown -s -t 1 -c "shutting down"
Now, in simba call this to shut down the pc:
OpenWebPage('c:\sd.bat');
Probably not the best way, but it works :P
this is my favourite simple and elegant. u could make it create the sd.bat to if you wanted to redistribute it. better than my idea.
Powered by vBulletin® Version 4.2.1 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.