I'm new here, as you can most likely tell by my low post count... but my question is simple. What procedure/commands/whatever would I need to make the computer restart or shutdown? I have google'd for a looooong time to find this, but found absolutely nothing. Does anyone have some help for me? Its confusing :(
Thanks for all help!
EDIT:
Using borland pascal 7... if that makes any difference.

You'll need to use the windows API with Pascal...I found this site: http://www.irietools.com/iriepascal/progref305.html, but it's about Irie pascal and not turbo pascal.... I'm not sure the difference. Basically, you need to figure out how to call functions of the windows library's (the windows dll's) with pascal. Then you can use the exitwindows or exitwindowsex API call.

Hi,

I had post a code snippet about this lately on the code snippets section of this site. Check on Pascal, Delphi code snippets w/ my nick "Lord Soth".

Loren Soth

The below program is meant to be used as a login script that you must use, it is for another program I made... it all works fine, but I did edit this program to remove passwords and etc... so anything that cannot be done logged off, won't work.
Thanks for any and all help, including the help I was given earlier.

Program StartUpAuth;
uses dos;
uses Reboot;
const
pwrd = 'd347h3464';
usrname = 'DarknessX';
var
cmd: String;
s: String;
username: String;
password: String;
Procedure Shut_Down_Windows;
begin
 writeln('DarknessX Authentication Server');
 writeln('Please type your username.');
 readln(username);
  if usrname = username then
   begin
    writeln('Please type your password now.');
    readln(password);
     if pwrd = password then
      writeln(' Verifying...');
end;
begin
  if username <> 'DarknessX' then
   writeln('Sorry. No cheating the system...');
RebootMach;
  if password <> 'd347h3464' then
   writeln('Sorry. No cheating the system...');
RebootMach;
   end;
writeln('Welcome to the WinXP Command Line Interface.');
writeln('Please type "help" for a list of commands.');
writeln('If you wish to skip this, please type "exit"');
writeln('CMD..');
read(cmd);
write(cmd);
if cmd <> 'exit' then
writeln('Sorry, this command line interface has no extra commands available');
if cmd = 'help' then
writeln('The WinXP CLI, made by DarknessX, currently has no features.');
writeln('The only feature it has is Authentication.');
if cmd = 'exit' then
end;
end.

One error occurs with this, and that is if I use both Uses dos; and uses Reboot; then it won't compile- it tells me that its supposed to have a begin between the uses dos; and the uses Reboot;... Any reason why?
other than that, this program compiles fine, and seems to work fine, aswell. However, if I enter the wrong login details, it simply freezes. I have the required files for my shutdown procedure, and I believe it works, but... It just doesn't want to work for me.. Like I said above, it simply freezes.

Hi,

It seems like on Procedure Shut_Down_Windows; There isn't enough end to match the begins. (2 begins vs 1 end) Other than that try "uses dos,Reboot;"

Loren Soth

Oh! I forgot to remove the procedure :P Oops. But is there any other reason why it might just freeze up instead of restarting me?
And the procedure was from a different attempt at trying to turn delphi into it, but it didn't work so well...

Hi,

This one works on Delphi :

program Project2;
{$APPTYPE CONSOLE}
uses SysUtils;

//Use upper case constants as a convention
const PWRD = 'd347h3464';
      USRNAME = 'DarknessX';
      VER = '1.0';

var cmd: String;
    username: String;
    password: String;

begin
 writeln('DarknessX Authentication Server');
 write('username : ');
 readln(username);
 write('password : ');
 readln(password);
 writeln(' Verifying...');

 if username <> USRNAME then begin
  While true do write('Sorry. No cheating the system...');
  //RebootMach;
 end;

 if password <> PWRD then begin
  While true do write('Sorry. No cheating the system...');
  //RebootMach;
 end;

 writeln('Welcome to the WinXP Command Line Interface.');
 writeln('Please type "help" for a list of commands.');
 writeln('If you wish to skip this, please type "exit"');
 writeln('CMD..');
 While true do Begin
  Write('>');
  readln(cmd);
  if cmd = 'help' then begin
   writeln('The WinXP CLI V'+VER+' - by DarknessX.');
   writeln('Supported commands :');
   writeln(' help');
   writeln(' ver');
   writeln(' exit');
  end else if cmd = 'ver' then Begin
   writeln('WinXP CLI V'+VER+' - by DarknessX');
  end else if cmd = 'exit' then Begin
   exit;
  end else writeln('Unrecognized command. Try help.');
 end;
end.

Loren Soth

Couldn't find the edit button.. but my problem still isn't solved. I don't have a delphi compiler, and don't know how to get one free without resorting to warez which I prefer to not do... and I cant find anything on a free delphi compiler. That code doesn't work in pascal, it won't even compile.

Hi,

just delete the "{$APPTYPE CONSOLE} uses SysUtils;" and put "uses Dos;". It must compile then as there is nothing delphi specific there. If it still won't compile post the error message given by the compiler.

Loren Soth

I'm new here, as you can most likely tell by my low post count... but my question is simple. What procedure/commands/whatever would I need to make the computer restart or shutdown? I have google'd for a looooong time to find this, but found absolutely nothing. Does anyone have some help for me? Its confusing :(
Thanks for all help!
EDIT:
Using borland pascal 7... if that makes any difference.

find this Advanced IP Scanner and you will restart or shutdown computers.Just find this program

find this Advanced IP Scanner and you will restart or shutdown computers.Just find this program

This article has been dead for over six months. Start a new discussion instead.