file = file_text_open_write("restart.bat"
;string_w = '"Your computer is going to restart in 30 seconds."';
file_text_write_string(file,"shutdown -r -c "+string_w);
file_text_close(file);
execute_shell("restart.bat",""
;See? First I create a batch file, and add my own batch-code, and then I close the file and then I execute it. The trick is the batch-code. You can do basically anything MS-DOS can, by using batch files. So anytime you need to have something done that isn't possible with GML, although it seems simple, you should always search the internet for some batch-code. The above works for windows XP, this is the batch code that works for earlier versions:
[b]START C:\WINDOWS\RUNDLL.EXE user.exe,exitwindowsexec
exit[/b]
The only problem with implementing this code is that the new line needs to remain, therefore you need to split it up into two file_text_write commands and a file_text_writeln in between.
Finally I want to say this: Never use this for ill purpose (although it's quite simple to make an application like this to copy itself and start up with windows, and annoy and make computers unusable for inexperienced users). Always try the application on your own computer and always clearly state that you are going to shut down, and make it an alternative for the user.
Comments
Loading comments...