Shutdown Windows after simulation

Yes, look at the function shutdown in the package fun.

The flags for system command shutdown depends on your operating system, the function simply calls the appropriately flagged command.

fun::shutdown

function (wait = 0) 
{
    Sys.sleep(wait)
    ifelse(.Platform$OS.type == "windows", shell("shutdown -s -t 0"), 
        system("shutdown -h now"))
}

R can send commands to the system with ?system, and so whatever is required for Windows can be done with that:

http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/shutdown.mspx?mfr=true

R has a .Last() function controlled by quit() (or q()) with its runLast argument, so this is where you would send the shutdown commands via system, so that it occurs after quitting R. Saving objects with R is done with save or save.image, though there is a default to save as well with quit().

Tags:

R