Created
October 7, 2019 02:57
-
-
Save parzibyte/925b055fb56f700f74e4d46b74551038 to your computer and use it in GitHub Desktop.
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 obtenerListaDeImpresorasCompartidasWindows() []string { | |
salida, err := exec.Command("cmd", "/C", "wmic", "printer", "get", "name").Output() | |
if err != nil { | |
log.Fatal(err) | |
} | |
salidaCadena := string(salida) | |
listaDeImpresoras := strings.Split(salidaCadena, "\r\r\n") | |
var listaDeImpresorasLimpias []string | |
for _, impresora := range listaDeImpresoras { | |
nombreLimpio := strings.TrimRight(impresora, " ") | |
if len(nombreLimpio) > 0 && nombreLimpio != "Name" { | |
listaDeImpresorasLimpias = append(listaDeImpresorasLimpias, nombreLimpio) | |
} | |
} | |
return listaDeImpresorasLimpias | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment