#include <stdio.h>
void main()
{
char str[10], str1[10];
system("COLOR 74");
system("title Password Change ");
system("mode con: cols=140 lines=30");
printf("\n\nWelcome to 'Jubayer IT Solution' Refresher'in C Programming App!!");
printf("\n\nType Your Desired Name and Hit 'Enter' Key to Create a New User!!\n\n>>");
scanf("%s",str);
printf("\n\nType Your Desired Password and Hit 'Enter' Key to set a password of %s !!\n\n>>", str);
scanf("%s",str1);
system("net user /add %s %s", &str, &str1);
system("COLOR 27");
printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nSuccessfully You Have Changed Your Password\n\n\nYour new User Name is-----: %s\n\n Your Password is----:%s\n\n" ,str, str1);
printf("\n\n\n\n\n\n\n\Thanks for using my simple Application. The program is composed by Md. Taufiq Jubayer\nCreated 2.11am December 2017\n");
printf("Press any key to exit.\n");
_getch();
exit(0);
return 0;
}

Recommended Answers

All 3 Replies

Sorry but this looks, what's the word here? Primitive. It also doesn't look to be for many versions of Windows today. You can imagine what chaos would happen if this worked today.

I will mention that a System call should degrade rights.

It also doesn't look to be for many versions of Windows today.

I ran this program as an Administrator...

#include <cstdlib>
using namespace std;
int main()
{
    system("net user /add AssertNull abcd1234");
    return 0;
}

And I see a new user called AssertNull on my computer. I haven't logged in yet, but it's there. I'm running Windows 10. Thus I imagine the problem is the OP's basic C++ program itself. Since the OP has not returned and was not specific in the exact problem, I am not going to debug it for him.

You can imagine what chaos would happen if this worked today.

It did work today. What chaos are you concerned about?

I will mention that a System call should degrade rights.

I don't know if it SHOULD or not, but clearly it doesn't?

If I can create a new user by typing the above into a command line or I can create a new user by sticking the above in a batch program, why is it bad to stick it in a C++ program and run it as a system call?

@AssertNull. When the old System() call ran from old TurboC which they didn't tell, a new instance of the shell can start without the admin rights. If yours worked then it could be something in your choice of compiler. We may not know untile the OP posts back.

The code does look primitive to me in the use of System rather than API calls.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.