?
Solved

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

Posted on 2000-05-02
27
Medium Priority
?
371 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 14
  • 13
27 Comments
 
LVL 9

Accepted Solution

by:
ShaunWilde earned 600 total points
ID: 2772604
have you looked at the ::ExitWindowsEx API?
0
 

Author Comment

by:Berm
ID: 2782943
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
ID: 2782967
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
Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

 

Author Comment

by:Berm
ID: 2828626
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
ID: 2829395
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
ID: 2830479

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
ID: 2831106
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
ID: 2831839
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
ID: 2832356
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
ID: 2832411
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
ID: 2833935
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
ID: 2833995
As I said have you tried using REMOTE ?
0
 

Author Comment

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

Is it correct ?  
0
 
LVL 9

Expert Comment

by:ShaunWilde
ID: 2834075
no I actually meant the command line utility REMOTE
0
 

Author Comment

by:Berm
ID: 2834087
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
ID: 2834125
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
ID: 2834213
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
ID: 2835983
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
ID: 2836318
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
ID: 2836653
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
ID: 2836815
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
ID: 2837899
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
ID: 2838288
as long as it isn't NT2000 specific it should be okay
0
 

Author Comment

by:Berm
ID: 2838431
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
ID: 2840516
** 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
ID: 2840521
> 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
ID: 2840641
found a new API that you may find of use

InitiateSystemShutdown and InitiateSystemShutdownEx

0

Featured Post

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month9 days, 7 hours left to enroll

762 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