How to add a user into a specific domain using CMD? - cmd

In Windows 7, let's say I want to create a user in a specific domain using CMD. If the username is user.name, the password is password and the domain is DMN (the domain my computer is currently connected to), what would the command be? I know the syntax for the net user command is
net user [<UserName> {<Password> | *} [<Options>]] [/domain]
but i've attempted the command
net user user.name password /ADD DMN
and it doesn't work.
What should I do? Is there a proper command for this?
Thanks in advance.

When adding a new domain user with NET USER you don't name the domain. The command executes on the current domain as below.
NET USER user.name password /ADD /DOMAIN

Related

CMD Command for checking if Local User account exists and create if doesn't

I am looking a single line CMD command to check if local user exists & create if it doesn't exist.
I am aware about command to create a user:
"net user UserName Password /ADD"
As well as for checking if the user exists or not:
"net user | find /i UserName"
Though trying to see if there is a way to join these 2 commands to yield the desired result.
Any guidance would be greatly appreciated.
How about using a condition based on whether the user exists?
SET "THEUSER=username"
NET USER "%THEUSER%" 1>NUL 2>&1 || NET USER "%THEUSER%" Password /ADD

Cannot logon windows after changing password via net user newuser command

I was trying to change my windows password via command:
net user Adminstrator newpassword
However, I accidentally did this
net user Administrator "newpassword"
There is no special character in the password
Now I am not able to logon my Administrator account via either newpassword or "newpassword"
Please help.
Thank you.
Best regards,
Apparently it is an issue for Windows password change command, that you cannot put double quotes in the password, and if you did, the command will be executed successfully but nobody knows what the password is.
I resolved this issue via resetting admin password to default following the instruction at:
http://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ResettingAdminPassword_EC2Config.html
I was lucky I am having this issue with AWS EC2 instance, otherwise I won't be able to resolve like that.
It happens when using escape sequence in command prompt
Run the following command in command prompt with administrator privilege
echo EnteredPassword >> C:\ActualPassword.txt
EnteredPassword is the password that you entered in the command prompt
And your actual password will be available in C:\ActualPassword.txt

Cannot access the cmd through new admin account

I made an admin account using the following command on the cmd:
net localgroup administrators [username] /add
But now whenever I try to access the cmd it says that either the file has not been found or I don't have permission to access the file.
could you clarify?
Are you:
1) Saying you can't run cmd.exe after logging in as a new user?
(IF so, that sounds like an issue for serverfault)
2) saying that you can't add the User you already created to the local group from the CMD?
(If so, have you Tried right clicking and running the CMD as an administrator?)
3) Saying you are trying to create a user and add it using only this one command?
(If so, you cannot do this. You Must create a user first before you can add it to a group. to create a user at the CMD Prompt, you can use the "Net User" Command such as this:
NET USER [UserName] [password] /ADD
NET Localgroup [GroupName] [UserName] /ADD
e.g. Assuming the user you want to add is named "Joe", and you want the password to be "Abcd1234!" you would use the following:
NET USER Joe Abcd1234! /ADD
NET Localgroup Administrators Joe /ADD
)
4) Some other option?
If one through three the above responses should help.

Check if Local User account exists and create it if it doesn't exist

I'm trying to write a command line script that will check if an local user account exists and create that account if it doesn't.
I have the two commands, but I want to put it together into a conditional check.
Command to check if the account exists.
Net user | find /i "Username"
Here's the command to create the account.
NET USER Username {Password} /EXPIRES: NEVER /ADD
Also, I'm having problems with the /Expires switch working. When I check the account's settings it doesn't have "Password never expires" as checked.
The /Expires switch is for the account, not the password. Try running this from PowerShell.
$user = "User3"
NET USER $user "Good1!PW" /Add
Set-LocalUser -Name $user -PasswordNeverExpires $true -UserMayChangePassword $false

Single line command for Run as a different user on Windows 7 that contains a password also

Is there any single line command for Run As Different User in Windows 7.
I am using following command but then it ask for password
runas /user:USER-NAME "C:\full\path\of\Program.exe"
Is there any way to supply password also in above line ? Actually i am launching application from other application so I don't want any user interaction But in above command it ask user for PASSWORD
PsExec in the MS SysInternals suite:
psexec -user Administrator -p Passwd "xcopy a.xml \\server_over_there\c$\A.xml"
In case the local user is NOT what you need and a specific DOMAIN user is, use:
/user Username in form USER#DOMAIN or DOMAIN\USER
(USER#DOMAIN is not compatible with /netonly)

Resources