Created
June 25, 2023 06:39
-
-
Save yangyang5214/23d5cc21052d2d8c04712e73363a5ac8 to your computer and use it in GitHub Desktop.
create windows user
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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