คำสั่ง net เพิ่ม,ลบ user บน Windows XP

Filed under: Users, Windows — Tags: , — editor @ 3:51 pm


อาจเนื่องมาจากคุ้นเคยกับการใช้คำสั่ง command line บนลีนุกซ์ หรือ UNIX เพื่อแก้ไขคอนฟิกต่างๆ ของเครื่องเป็นเวลานาน เมื่อต้องมาทำบน Windows เช่นครั้งนี้ได้รับมอบหมายงานให้เพิ่ม local user จำนวนมากบนเครื่อง Windows XP หลายๆ เครื่อง แต่ห้ามคอนฟิกเป็น domain controller จึงหาวิธีการทำโดยใช้การรันคำสั่ง command line บน Windows

จากการค้นหาบน google มีอยู่หลากหลายวิธีที่จะเพิ่ม local user ได้ ทั้งการเขียนโปรแกรม สร้าง WSH (Windows Script Host) หรือล่าสุดที่ทาง Microsoft นำเสนอทางเลือกใหม่คือ Windows PowerShell

แต่ดูแล้วค่อนข้างจะยุ่งยาก บางอย่างเช่น Windows PowerShell ต้องมีการติดตั้งโปรแกรมใหม่ ซึ่งทางลูกค้าไม่ต้องการให้เป็นเช่นนั้น

สุดท้ายมาลงเอยโดยใช้คำสั่ง net ซึ่งมีติดตั้งมาอยู่แล้วกับ Windows XP ทางผู้เขียนเพิ่งทราบเหมือนกันว่า สามารถใช้คำสั่งนี้ เพิ่มลบ user ได้ รวมทั้งสามารถคอนฟิกอื่นๆ ได้อีกด้วย

วิธีการรันคำสั่ง net

ล็อกอินเป็น Administrator หรือมีสิทธิเทียบเท่า เพื่อแก้ไข user account ได้

เพื่อความสะดวกในการทดลอง แนะนำให้เปิด command line ของ Windows ก่อน โดยสามารถรันได้จากคลิ้ก Start -> Run พิมพ์คำว่า cmd ในช่อง Open แล้วกดปุ่ม [OK}















พิมพ์คำสั่ง net หน้าจอจะแสดง syntax ในการรันคำสั่งต่างๆ ซึ่งแยกตามหมวดต่างๆ

C:\Documents and Settings\Administrator> net
The syntax of this command is:


NET [ ACCOUNTS COMPUTER CONFIG CONTINUE FILE GROUP HELP
        HELPMSG LOCALGROUP NAME PAUSE PRINT SEND SESSION
        SHARE START STATISTICS STOP TIME USE USER VIEW ]


ในที่นี้เราจะจัดการเกี่ยวกับ user สามารถพิมพ์คำสั่ง net user "/?" เพื่อแสดงวิธีการใช้คำสั่งเกี่ยวกับ user

C:\Documents and Settings\Administrator> net user /?
The syntax of this command is:

NET USER
[username [password *] [options]] [/DOMAIN]
        username {password *} /ADD [options] [/DOMAIN]
        username [/DELETE] [/DOMAIN]


หากต้องการรายละเอียดมากขึ้นเกี่ยวกับการใช้คำสั่ง ให้พิมพ์ต่อท้ายด้วย "/help"

C:\Documents and Settings\Administrator> net user /help
The syntax of this command is:NET USER

[username [password *] [options]] [/DOMAIN]
         username {password *} /ADD [options] [/DOMAIN]
         username [/DELETE] [/DOMAIN]

NET USER creates and modifies user accounts on computers. When used without switches, it lists the user accounts for the computer. The user account information is stored in the user accounts database.

This command works only on servers.

username Is the name of the user account to add, delete, modify,
              or view. The name of the user account can have as many
              as 20 characters.
password Assigns or changes a password for the user's account.
              A password must satisfy the minimum length set with the
              /MINPWLEN option of the NET ACCOUNTS command. It can
              have as many as 14 characters.
*            Produces a prompt for the password. The password is not
              displayed when you type it at a password prompt.
              /DOMAIN Performs the operation on a domain controller of
              the current domain.
/ADD       Adds a user account to the user accounts database.
/DELETE   Removes a user account from the user accounts database...


ไม่มีความคิดเห็น:

แสดงความคิดเห็น