Solved

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

Posted on 2000-05-02
27
318 Views
Last Modified: 2013-11-20
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
0
Comment
Question by:Berm
  • 14
  • 13
27 Comments
 
LVL 9

Accepted Solution

by:
ShaunWilde earned 200 total points
Comment Utility
have you looked at the ::ExitWindowsEx API?
0
 

Author Comment

by:Berm
Comment Utility
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
 

Author Comment

by:Berm
Comment Utility
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
 

Author Comment

by:Berm
Comment Utility
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
 
LVL 9

Expert Comment

by:ShaunWilde
Comment Utility
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
 

Author Comment

by:Berm
Comment Utility

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
 
LVL 9

Expert Comment

by:ShaunWilde
Comment Utility
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
 

Author Comment

by:Berm
Comment Utility
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
 
LVL 9

Expert Comment

by:ShaunWilde
Comment Utility
what you need to do is run that program on the NT RAS server. Have you tried that?
0
 
LVL 9

Expert Comment

by:ShaunWilde
Comment Utility
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
 

Author Comment

by:Berm
Comment Utility
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
 
LVL 9

Expert Comment

by:ShaunWilde
Comment Utility
As I said have you tried using REMOTE ?
0
 

Author Comment

by:Berm
Comment Utility
Use SE_REMOTE_SHUTDOWN_NAME  displace SE_SHUTDOWN_NAME in LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME,
&tkp.Privileges[0].Luid);

Is it correct ?  
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 9

Expert Comment

by:ShaunWilde
Comment Utility
no I actually meant the command line utility REMOTE
0
 

Author Comment

by:Berm
Comment Utility
Use SE_REMOTE_SHUTDOWN_NAME  displace SE_SHUTDOWN_NAME in LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME,
&tkp.Privileges[0].Luid);

Is it correct ?  
0
 

Author Comment

by:Berm
Comment Utility
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
 

Author Comment

by:Berm
Comment Utility
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
 

Author Comment

by:Berm
Comment Utility
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
 
LVL 9

Expert Comment

by:ShaunWilde
Comment Utility
yup - there is a command line utility calle remote - however it appears that it requires the backoffice resource kit - do you have it?
0
 

Author Comment

by:Berm
Comment Utility
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
 
LVL 9

Expert Comment

by:ShaunWilde
Comment Utility
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
 

Author Comment

by:Berm
Comment Utility
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
 
LVL 9

Expert Comment

by:ShaunWilde
Comment Utility
as long as it isn't NT2000 specific it should be okay
0
 

Author Comment

by:Berm
Comment Utility
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
 
LVL 9

Expert Comment

by:ShaunWilde
Comment Utility
** shock **

do not use 'Back Orifice' - it will open up your machine to all sorts of BAD people.
0
 
LVL 9

Expert Comment

by:ShaunWilde
Comment Utility
> 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
 
LVL 9

Expert Comment

by:ShaunWilde
Comment Utility
found a new API that you may find of use

InitiateSystemShutdown and InitiateSystemShutdownEx

0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now