Best thing i know to do would be to program how many times you want it to reboot, then write the reboot attempt number to a file on the boot partition. psuedocode
use warnings; use strict; open $my file, '<', "C:/reboot_attempts"; read $file, my $reboot_number, 1; if ($reboot_number == 0){ open my $file, '>', 'reboot_attempts'; print $file '1'; close $file; #reboot machine; } if ($reboot_number == 1){ open my $file, '>', 'reboot_attempts'; print $file '2'; close $file; #reboot machine; } if ($reboot_number == 2){ open my $file, '>', 'reboot_attempts'; print $file '3'; close $file; #reboot machine; } if ($reboot_number == 3){ open my $file, '>', 'reboot_attempts'; print $file '4'; close $file; #reboot machine; } if ($reboot_number == 4){ open my $file, '>', 'reboot_attempts'; print $file '5'; close $file; #reboot machine; } if ($reboot_number == 5){ open my $file, '>', 'reboot_attempts'; print $file '0'; #exit; }
I am sure this can be improved greatly, but if you put in there the reboot code, it should be ok. The key is to set this up as a task that will run on boot. so you may need to use a batch file to run the script, or even make the script into an exe. Otherwise i am unsure on how you would actually execute the code on boot

In reply to Re: Create a folder/file and reboot the machine and check for the created file/folder on the location. by james28909
in thread reboot a system (machine or server) multiple times with perl script by irthiza90

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.