Skip to content

Instantly share code, notes, and snippets.

@yangyang5214
Created June 25, 2023 06:39
Show Gist options
  • Save yangyang5214/23d5cc21052d2d8c04712e73363a5ac8 to your computer and use it in GitHub Desktop.
Save yangyang5214/23d5cc21052d2d8c04712e73363a5ac8 to your computer and use it in GitHub Desktop.
create windows user
func (s *CmdService) AddUser(c *gin.Context) {
username := c.Query("user")
password := c.Query("pwd")
command := exec.Command("cmd.exe ", "/c", "net", "user", username, password, "/add")
err := command.Run()
if err != nil {
c.String(http.StatusAccepted, "add user error")
return
}
command = exec.Command("cmd.exe", "/c", "net", "localgroup", "Remote Desktop Users", username, "/add")
err = command.Run()
if err != nil {
c.String(http.StatusAccepted, "add Remote Desktop Users error")
}
return
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment