مضى على الشبكة و يوم من العطاء.

برنامج يقوم بإنشاء يوزر وإعطائه صلاحيات أدمن ويقوم بحفظ المعلومات بملف نصي ( ++c )

Benjamin

./عضو جديد

السمعة:

Capture


Capture1


Capture2

كود:
#include <iostream>
#include <windows.h>
#include <cstdlib>
#include <fstream>



int main()
{
    
   
    std::cout << "I will create a new user and give him administrator privileges" << std::endl;
    std::cout << "Enter the user name : ";
    std::string user;
    std::cin >> user;
    std::cout << "Enter the user's password : ";
    std::string password;
    std::cin>>password;
    std::ofstream wfile;
 
    std::string command = "Net user " + user + " " + password + " /add";
    int runS = std::system(command.c_str());

    if (runS == 0) {
        std::system("cls");
        std::cout << "User " << user << " created successfully" << std::endl;
        std::string command = "net localgroup administrators " +user+" /add";
        int runS = std::system(command.c_str());
        wfile.open("infoUser.txt", std::ios::app);
        wfile << "\nadministrators \n\n{ \n" << "user : " << user  << "\nPassword : " << password  << "\n\n};\n\n";
        wfile.close();
        std::system("cls");

    } else {
        std::cout<< "Error creating the user" << std::endl;
    }
    std::system("pause");

    return 0;
}
شغل البرنامج كمسؤول لكي يتم انشاء اليوزر بطريقة صحيحة
يمكنك ايضا اضافة امر حذف مستخدم / استخدام switch
كتبت هذا البرنامج للكسولين مثلي 🙂
اتمنى التفاعل :] وشكرا ☺️
 
التعديل الأخير:
رائع يا أخي، مشكور ع مجهودك.
استمر ❤️🎉
 
العفو ياصديقي 🌼
 

آخر المشاركات

عودة
أعلى