I found the syntax to change a user password through command prompt. I am using:
net user username password

I have sucessfully changed the password to a regular password. I can not figure out how to change it to a pass-sentence. How would I write the syntax for a password with spaces in it? 
For instance, please explain how I would write "My new password." in cmd...because this doesnt work:
net user testuser2 My new password.                                   

I am sure that it is case sensative, no? If its case sensative for the password, why wont it recognise the sapces as part of the password? 

Thank you for your time.

Dani AI

Generated

Quick summary: wrapping the whole password in double quotes makes CMD treat spaces as part of the same argument — exactly what suggested and what later confirmed. Quoting is the simple fix for passphrases; if a quoted string still misbehaves, the shell is probably interpreting other special characters. (learn.microsoft.com)

CMD parsing caveats and common pitfalls: double quotes protect spaces and most punctuation, but some characters still get special handling. In batch files a percent sign (%) is treated as a variable marker and must be doubled (%%). An exclamation mark (!) can be consumed by delayed expansion; caret (^) is the escape character; ampersand (&), pipe (|) and redirection (<, >) can split or redirect the command if not handled. A practical trick inside a .bat is to build the password into a variable (with proper escaping) and then use that variable. Example (showing percent escaping in a batch file):

REM in a .bat file: a literal percent requires doubling
set "pw=100%%secure"

See SS64 / batch-escaping references for details. (ss64.com)

Security and alternatives: avoid placing plaintext passwords on a command line. The net user command supports using an asterisk to prompt for the password (so it never appears in the process arguments), and modern Windows provides PowerShell cmdlets that accept SecureString objects. Example PowerShell pattern (creates a SecureString then applies it with the local-account cmdlet):

$pw = ConvertTo-SecureString 'My pass with spaces!^%' -AsPlainText -Force
Set-LocalUser -Name 'testuser' -Password $pw

Using a prompt or SecureString also avoids many shell-escaping headaches. (learn.microsoft.com)

Extra notes: Windows accepts long passphrases (interactive logon up to 127 characters) and passwords are generally treated case-sensitive on modern systems; legacy down-level clients or old LAN Manager compatibility can produce case-insensitive behavior in rare environments, so treat passphrases as case-sensitive and be aware of domain/compatibility policies. If quoting still fails, run the prompt elevated (changing another account’s password requires appropriate privileges), test with a simple no-space password to confirm permissions, then reapply quoting/escaping. (learn.microsoft.com)

Recommended Answers

All 3 Replies

wow, sorry thats so messy. still trying to understand all the errors i get when i try to post!!!

Have you tried
net user <user> "this is the password"

I don't know if that will work but worth a shot. ALthough you may end up with a password being "this

thats perfect. im still so new at this, using quotations would have never crossed my mind. thanks!

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.