Benjamin
./عضو جديد



السمعة:
- إنضم20 سبتمبر 2023
- المشاركات 15
- مستوى التفاعل 40
- النقاط 13
كود:
#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
كتبت هذا البرنامج للكسولين مثلي

اتمنى التفاعل :] وشكرا

التعديل الأخير: