Shutdown the servers with RAS of NTservice by UID & PWD administrator

Hi everyone,

     Can you help me ?
Let me know the sample code with MFC for shutdown the server in my office with RAS via my modem at home.
     For this case,I need to do something about my work on the server during the night at my home and thereafter I need shutdown it with RAS of NT service via my modem into com port on the server.
     If you have method or sample code with MFC for managing it,please kind me and let me know on the experts exchange or my e-mail at "bermusa@usa.net" that I am really appreciative of your kind and your help with my sincerity.

       Thank you very much beforehand.

       Best Regards,
       Berm
BermAsked:
Who is Participating?
 
ShaunWildeConnect With a Mentor Commented:
have you looked at the ::ExitWindowsEx API?
0
 
BermAuthor Commented:
Hi,

     I already went there - which did the section that I must use ?
     Would you please tell me too ?
      Thank you very much.

      Regards,
      Berm

0
 
BermAuthor Commented:
Hi,

     I already went there - which did the section that I must use ?
     Would you please tell me too ?
      Thank you very much.

      Regards,
      Berm

0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
BermAuthor Commented:
Hi ShaunWilde,

     Thank you very much for your information.OK,I accepted your answer,but I already went there - which did the section that I must made it ?
     Would you please tell me again ?
      Thank you very much.

      Regards,
      Berm





0
 
ShaunWildeCommented:
Hi - Sorry for not responding sooner - but I didn't receive (or don't remember receiving) any message that you had reposted.

I'd look at EWX_REBOOT or EWX_SHUTDOWN option for the command and the EWX_FORCEIFHUNG and/or EWX_FORCE options

however this could be supplied as switches to the application.

As this is NT you need to get the right permissions esp SE_SHUTDOWN_NAME.

Is this what you were querying or is there something else I can help with
0
 
BermAuthor Commented:

Hi ShaunWilde,

    Thank you very much for your comment.OK,I'm a network administrator in my office,so I can do everything for managing remote host.
    I could make successful for shutdown a local PC on Win95 & 98 with my app - from code below :

if (Msg == IDYES)
      {
                  // Shutdown Computer for Win95 & Win98
            HANDLE hToken;
            TOKEN_PRIVILEGES tkp;
 
            // Get a token for this process.

            if (!OpenProcessToken(GetCurrentProcess(),
                  TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
            //error("OpenProcessToken");
            //AfxMessageBox("OpenProcessToken");
 
            // Get the LUID for the shutdown privilege.
 
            LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME,
                  &tkp.Privileges[0].Luid);
 
            tkp.PrivilegeCount = 1;  // one privilege to set    
            tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
 
            // Get the shutdown privilege for this process.
 
            AdjustTokenPrivileges(hToken, FALSE, &tkp, 0,
                  (PTOKEN_PRIVILEGES)NULL, 0);
 
            // Cannot test the return value of AdjustTokenPrivileges.
 
            if (GetLastError() != ERROR_SUCCESS)
                  //error("AdjustTokenPrivileges");
                  //AfxMessageBox("AdjustTokenPrivileges");
            if (!ExitWindowsEx( EWX_SHUTDOWN | EWX_POWEROFF, 0))
                  AfxMessageBox("ExitWindowsEx");
      }
      else
            Msg = IDNO;

///////////////////////////////////////

I would like you suggest me a little.If I need shutdown or restart remote host on my network which it is connecting and working to my PC at home via RAS service of  NT,that how do I need to adjust or edit my code ?
     If you will kind,please suggest me too.
     Thank you very much ,beforehand.

     Best Regards,
     Berm

P.S. Now,I'm waiting for your answer and help from you.
0
 
ShaunWildeCommented:
I am sorry but I do not understand your question.

Does the above code shutdown the NT RAS server?

Are you now trying to shutdown another server that you can see when you are connected by RAS?
0
 
BermAuthor Commented:
Hi,

In the first question :
Yes sir,you understand correct.
I need to change above code shutdown the NT RAS server.

Second your question :

      That is not correct yet.Please forgive me that I'm not clear with my question.Now,I can made successful with above code for shutdown the PC standalone from my app.It didn't the server - I only tested
the code that how it worked on PC standalone,so I want to help or recommendation from you for adjusting the code and let it can work with NT RAS server while I am connecting with it.Now,I can not make it successfully for NT RAS server.

     Please recommend me too.Thank you very much,beforehand.

     Best Regards,
     Berm.
0
 
ShaunWildeCommented:
what you need to do is run that program on the NT RAS server. Have you tried that?
0
 
ShaunWildeCommented:
sorry - not quite finished my message

you could try opening a remote console
'remote' on the commandline

if it is not possible you could try putting that code into a service on the NT machine - you can then talk to that service remotely using sockets or COM (if you use the ATL wizard then COM might be easier if you set up the DCOM parts correctly)
0
 
BermAuthor Commented:
Hi ShaunWilde,

    On my want,I need to manage shutdown/restart the NT RAS server from my app (exe file) at home machine that it is a local machine to connect with the NT RAS server at my office by distance about 30 km. from my home to my office via the modem total two modems.One modem is at home and one modem is at office.
   Now,I could shutting down successfully on machine at home from code above,and that it is directly shutting down from my app. without connecting via modem for shutting down it.
   In case for my problem,I want to shutdown or restart the NT RAS server via modem from my home to the office which I connect it on the night for my work.

   I hope,you would be understand for my problem in this time.
   Again,I want to help from you so that change my code for shutting down the NT RAS server from the local machine at home via the modem by distance about 30 km.

NOTE : I used uid/pwd administrator via the modem to connect with NT RAS server at my office that I could connect and could manage something successfully unless I could not successfully to make shutdown/restart it from the local machine at home.

    Would you help or get idea to me,please.

     Thank you very much.

     Best Regards,
     Berm

P.S. I would like to know about ATL using for COM and DCOM application.If possible,I hope you would be kind to give learning for me.
0
 
ShaunWildeCommented:
As I said have you tried using REMOTE ?
0
 
BermAuthor Commented:
Use SE_REMOTE_SHUTDOWN_NAME  displace SE_SHUTDOWN_NAME in LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME,
&tkp.Privileges[0].Luid);

Is it correct ?  
0
 
ShaunWildeCommented:
no I actually meant the command line utility REMOTE
0
 
BermAuthor Commented:
Use SE_REMOTE_SHUTDOWN_NAME  displace SE_SHUTDOWN_NAME in LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME,
&tkp.Privileges[0].Luid);

Is it correct ?  
0
 
BermAuthor Commented:
That I didn't know - where is the utility REMOTE for command line ?

Now the time,I am connecting to NT RAS server at my home.
Please tell me that how I need to make it ?

0
 
BermAuthor Commented:
I may a novice for you,please forgive me.
On my local machine at home runs on Win98 OS,but the office server runs on NT 4.0.

How will I resolve it ?
0
 
BermAuthor Commented:
Hi shaunWilde,

 Once again,
that meant I need to look for "REMOTE" command line or Remote Access Service (RAS) section on MSDN so that study an example at there,is it correct ?
  Please reply me,again.
  Thank you very much.

   Regards,
   Berm
0
 
ShaunWildeCommented:
yup - there is a command line utility calle remote - however it appears that it requires the backoffice resource kit - do you have it?
0
 
BermAuthor Commented:
As I remembered,I think in my office it would be has.

  If I have it,that mean I need to install it on the NT RAS server,needn't I ?
  When I already install it - how do I need to config it ?

0
 
ShaunWildeCommented:
I honestly don't know - however looking at the backoffice stuff there does seem to be a remote 'reboot' option which could be of use.

If backoffice is out of the question - you can always install you own service on the NT RAS server that will respond to requests either via COM (or sockets) and that can give you the capability you want.

0
 
BermAuthor Commented:
Thank you very much ShaunWilde.

Have a little :
   I ever hear about "Back Office 2000 (BO2K)" from cDc,that it can use,can't it ?
0
 
ShaunWildeCommented:
as long as it isn't NT2000 specific it should be okay
0
 
BermAuthor Commented:
Thank you again,I was mistake from "Back Office" name to correct was "Back Orifice"
 I will try to make it and if I have the problem,I hope you would be help me.
   If possible,you will give me email,won't you ?
0
 
ShaunWildeCommented:
** shock **

do not use 'Back Orifice' - it will open up your machine to all sorts of BAD people.
0
 
ShaunWildeCommented:
> If possible,you will give me email,won't you

if required - however I haven't used Back Office directly only via someone elses set up
0
 
ShaunWildeCommented:
found a new API that you may find of use

InitiateSystemShutdown and InitiateSystemShutdownEx

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.