Exemplo n.º 1
0
func query(key string) (regs []regedit.Reg, err error) {
	reg := regedit.New(regedit.Query, regedit.HKCU, "\\Environment")
	regcmd := reg.Search(regedit.Reg{Key: key})
	if regs, err = regcmd.Exec(); err != nil {
		P(ERROR, "search environment variable %v failed. Error: %v", PATH, err.Error())
	}
	return regs, err
}
Exemplo n.º 2
0
func add(key, value string) (err error) {
	reg := regedit.New(regedit.Add, regedit.HKCU, "\\Environment")
	regcmd := reg.Add(regedit.Reg{key, regedit.Types[regedit.SZ], value})
	if _, err = regcmd.Exec(); err != nil {
		P(ERROR, "add environment variable %v failed. Error: %v", NODE_HOME, err.Error())
	}
	return err
}