Commit 4620e4e1 by 陶腾飞

update

parent 1ef3e0b3
No preview for this file type
package main package main
import ( import (
"AD-Control/public" "AD-Control/public"
"time"
"flag" "flag"
) )
...@@ -14,10 +14,10 @@ func main(){ ...@@ -14,10 +14,10 @@ func main(){
var userText = flag.String(public.Msg_User,"","who is running me") var userText = flag.String(public.Msg_User,"","who is running me")
var wolmacText = flag.String("wolmac","","input mac address for wake pc") var wolmacText = flag.String("wolmac","","input mac address for wake pc")
var woluserText = flag.String("woluser","","input name for walk pc") var woluserText = flag.String("woluser","","input name for walk pc")
var runningText = flag.Bool("running",false,"runing daemon.exe & users.exe") var hourText = flag.Bool("hour",false,"exec task at the time")
flag.Parse() flag.Parse()
if *runningText {flag_running();return} if *hourText {flag_hour();return}
if *reportText != "" { flag_report(reportText,userText)} if *reportText != "" { flag_report(reportText,userText)}
if *backupText != "" { flag_bakcup(backupText)} if *backupText != "" { flag_bakcup(backupText)}
...@@ -46,6 +46,30 @@ func flag_wolmac(mac * string){ ...@@ -46,6 +46,30 @@ func flag_wolmac(mac * string){
func flag_woluser(user * string){ func flag_woluser(user * string){
public.PrintLog("暂未开发") public.PrintLog("暂未开发")
} }
func flag_running(){ func flag_hour(){
nh := time.Now().Hour()
public.PrintLog(nh)
switch nh{
case 0:
public.MsgBox(`5分钟后,即将重启,运行Z:\tools\【工具】取消关机.bat`)
public.Execcmd_nowait("shutdown -r -t 300")
break
case 1:
public.MsgBox(`5分钟后,即将重启,运行Z:\tools\【工具】取消关机.bat`)
public.Execcmd_nowait("shutdown -r -t 300")
break
case 2:
public.MsgBox(`5分钟后,即将重启,运行Z:\tools\【工具】取消关机.bat`)
public.Execcmd_nowait("shutdown -r -t 300")
break
case 3:
public.MsgBox(`5分钟后,即将关机,运行Z:\tools\【工具】取消关机.bat`)
public.Execcmd_nowait("shutdown -s -t 300")
break
case 4:
case 5:
case 6:
default :
break
}
} }
\ No newline at end of file
No preview for this file type
...@@ -2,14 +2,14 @@ package public ...@@ -2,14 +2,14 @@ package public
// app env //////////////////////////////////////////////////////////////// // app env ////////////////////////////////////////////////////////////////
const Debug bool = true //const Debug bool
const DaemonPort string = "16823" const DaemonPort string = "16823"
const DaemonListen string = ":" + DaemonPort const DaemonListen string = ":" + DaemonPort
const ADServerDaemon string = Env_MainADHostname + DaemonListen const ADServerDaemon string = Env_MainADHostname + DaemonListen
var LocalDaemon string = User_computername + DaemonListen var LocalDaemon string = User_computername + DaemonListen
const DocuBase string = `C:\Users\Public\Documents\AD-Control\` const DocuBase string = `C:\Users\Public\Documents\AD-Control\`
const RandMax int = 60 const RandMax int = 60
const Version string = "0.5.1" const Version string = "0.6"
const Application string = "AD-Control-Log" const Application string = "AD-Control-Log"
...@@ -43,8 +43,7 @@ var Env_ADMainDeptShare string = Env_ADMain + `\` + User_dept + `\` + "部 ...@@ -43,8 +43,7 @@ var Env_ADMainDeptShare string = Env_ADMain + `\` + User_dept + `\` + "部
const Env_ADSoftlike string = Env_ADSoft + `\` + "softlike" const Env_ADSoftlike string = Env_ADSoft + `\` + "softlike"
const Env_ADApplication string = Env_ADSoft + `\` + "application" + `\` const Env_ADApplication string = Env_ADSoft + `\` + "application" + `\`
const Env_ADSoftTool string = Env_ADSoft + `\` + "tools" + `\` const Env_ADSoftTool string = Env_ADSoft + `\` + "tools" + `\`
const Env_ADSoftTool_RebootUser string = Env_ADApplication + "reboot.bat" const Env_ADSoftTool_RebootUser string = Env_ADSoftTool + "upusers.bat"
const Env_ADSoftTool_Update string = Env_ADApplication + "update.bat"
const Env_ADsoftware_local string = `F:\software\softlike\` const Env_ADsoftware_local string = `F:\software\softlike\`
...@@ -119,7 +118,7 @@ const Msg_Exec_UserExec string = "userexec" ...@@ -119,7 +118,7 @@ const Msg_Exec_UserExec string = "userexec"
const Msg_Exec_RebootWindows string = "rebootWindows" const Msg_Exec_RebootWindows string = "rebootWindows"
const Msg_Exec_RebootWindows_cmd string = "shutdown -r -t 15" const Msg_Exec_RebootWindows_cmd string = "shutdown -r -t 15"
const Msg_Exec_UpdateVersion string = "updateverion" const Msg_Exec_UpdateVersion string = "updateverion"
const Msg_Exec_UpdateVersion_cmd string = Env_ADSoftTool_Update const Msg_Exec_UpdateVersion_cmd string = "Env_ADSoftTool_Update"
const Msg_Exec_InstallSoftware string = "installsoftware" const Msg_Exec_InstallSoftware string = "installsoftware"
......
...@@ -50,9 +50,7 @@ func (rep *MJreport)Msg_Deal() interface{} { ...@@ -50,9 +50,7 @@ func (rep *MJreport)Msg_Deal() interface{} {
case Msg_Report_UserStart: case Msg_Report_UserStart:
case Msg_Report_DaemonStart: case Msg_Report_DaemonStart:
if rep.Version == Version{ if rep.Version != Version{
return nil
} else{
return GJexecAck(Msg_Exec_UpdateVersion) return GJexecAck(Msg_Exec_UpdateVersion)
} }
default: default:
...@@ -84,7 +82,7 @@ func (exec *MJexec)Msg_Deal()interface{}{ ...@@ -84,7 +82,7 @@ func (exec *MJexec)Msg_Deal()interface{}{
exec.Command = Msg_Exec_RebootWindows_cmd exec.Command = Msg_Exec_RebootWindows_cmd
case Msg_Exec_UpdateVersion: case Msg_Exec_UpdateVersion:
exec.Command = Msg_Exec_UpdateVersion_cmd Exit()
} }
...@@ -112,18 +110,16 @@ func (exec *MJexec)Msg_Deal()interface{}{ ...@@ -112,18 +110,16 @@ func (exec *MJexec)Msg_Deal()interface{}{
full_cmd := "msiexec /i " + Env_ADSoftlike + `\` + exec.Command + " /qb" full_cmd := "msiexec /i " + Env_ADSoftlike + `\` + exec.Command + " /qb"
PsExec_sdi(exec.Computername,full_cmd,exec.SessionID) PsExec_sdi(exec.Computername,full_cmd,exec.SessionID)
} else {
// 对于 exe 格式 // 对于 exe 格式
// 从 ADMIN$ 复制到C:\windows } else {
// 如果文件存在,则执行C:\windows目录下的文件 // 如果文件存在,则执行C:\windows目录下的文件
if exec.Extbool { if exec.Extbool {
PsExec_sdi(exec.Computername,Dir_Windows + exec.Command,exec.SessionID) PsExec_sdi(exec.Computername,Dir_Windows + exec.Command,exec.SessionID)
// 如果文件不存在,从 ADMIN$ 复制到C:\windows,再执行
} else { } else {
PsExec_sdic(exec.Computername,Env_ADsoftware_local + exec.Command,exec.SessionID) PsExec_sdic(exec.Computername,Env_ADsoftware_local + exec.Command,exec.SessionID)
} }
} }
} }
default: default:
Execcmd_nowait(exec.Command) Execcmd_nowait(exec.Command)
......
package public package public
import ( import (
"log" "log"
//"os"
) )
func PrintLog(v ...interface{}){ func PrintLog(v ...interface{}){
if Debug {
log.SetPrefix("DEBUG ")
log.Println(v ...) log.Println(v ...)
} else {
log.Println(v ...)
}
// logFile, err := os.OpenFile(`C:\` + Application + ".txt", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0766) // logFile, err := os.OpenFile(`C:\` + Application + ".txt", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0766)
// if nil != err { // if nil != err {
...@@ -23,9 +17,3 @@ func PrintLog(v ...interface{}){ ...@@ -23,9 +17,3 @@ func PrintLog(v ...interface{}){
// loger.Println(v ...) // loger.Println(v ...)
// logFile.Close() // logFile.Close()
} }
// func PrintList(v ...*string){
// var b []byte
// for _,i := range v{
// append(b,v)
// }
// }
\ No newline at end of file
...@@ -163,11 +163,34 @@ func ReadDir(s string) ([]os.FileInfo,error){ ...@@ -163,11 +163,34 @@ func ReadDir(s string) ([]os.FileInfo,error){
f,err := ioutil.ReadDir(s) f,err := ioutil.ReadDir(s)
return f,err return f,err
} }
// func ReadDirModTime(s string) ([]string,error) { func GetNewestDir(rdir ,extdir string) string {
// f,err := ioutil.ReadDir(s) f,err := ioutil.ReadDir(rdir)
// var v []byte if err !=nil{
// append()v PrintLog(err)
// }
}
//var filearge := []byte
firstModTime := f[0].ModTime()
firstName := f[0].Name()
for _,i := range f{
fileModTime := i.ModTime()
filename := i.Name()
if i.IsDir() && i.Name() != extdir{
if firstModTime.Before(fileModTime){
firstModTime = fileModTime
firstName = filename
}
}
}
return firstName
}
func HasSuffix(str * string,sub string)bool{ func HasSuffix(str * string,sub string)bool{
return strings.HasSuffix(*str,sub) return strings.HasSuffix(*str,sub)
} }
fucn TrimSuffix(str ,s string)string{
return strings.TrimSuffix(str,s)
}
func Exit(){
os.Exit(0)
}
\ No newline at end of file
package public
import (
"reg"
)
...@@ -94,6 +94,9 @@ func PsExec_sdic(pc ,cmd ,sessionid string) { ...@@ -94,6 +94,9 @@ func PsExec_sdic(pc ,cmd ,sessionid string) {
func Msg(message string) { func Msg(message string) {
walk.MsgBox(*new(walk.Form), "提示", message, walk.MsgBoxIconInformation) walk.MsgBox(*new(walk.Form), "提示", message, walk.MsgBoxIconInformation)
} }
func MsgBox(message string){
Execcmd_nowait("msg * /TIME:60 "+ message)
}
func SysMsgBox(pc,message string){ func SysMsgBox(pc,message string){
Execcmd_nowait("msg * /SERVER:"+pc+" /TIME:60 "+ message) Execcmd_nowait("msg * /SERVER:"+pc+" /TIME:60 "+ message)
} }
......
...@@ -2,8 +2,6 @@ package main ...@@ -2,8 +2,6 @@ package main
import ( import (
"github.com/lxn/walk" "github.com/lxn/walk"
"AD-Control/public" "AD-Control/public"
"strings"
"os/exec"
) )
//--------------------------------------------------------- //---------------------------------------------------------
...@@ -97,7 +95,7 @@ func menuInitSoftwareInstall(ni * walk.NotifyIcon){ ...@@ -97,7 +95,7 @@ func menuInitSoftwareInstall(ni * walk.NotifyIcon){
if each == ".DS_Store"{ if each == ".DS_Store"{
continue continue
} }
each_noext := strings.TrimSuffix(strings.TrimSuffix(ueach.Name(),".exe"),".msi") each_noext := public.TrimSuffix(public.TrimSuffix(ueach.Name(),".exe"),".msi")
// 建立 子按钮 // 建立 子按钮
na := walk.NewAction() na := walk.NewAction()
...@@ -131,7 +129,58 @@ func siEnter_admin(softname string){ ...@@ -131,7 +129,58 @@ func siEnter_admin(softname string){
} }
//---------------------------------------------------------------
//
// WxDrive Sync
//
//---------------------------------------------------------------
func menuInitWxDriveSync(ni){
fa := "用户工具"
sub := [...]string{"初始化","开启服务器同步到微盘","开启微盘同步到服务器","说明"}
// 建立空菜单
nm,err := walk.NewMenu()
if err != nil {
public.PrintLog(err)
}
for i,buttonText := range sub{
// 建立 子按钮
na := walk.NewAction()
if err := na.SetText(buttonText); err != nil {
public.PrintLog(err)
}
// 为子按钮 添加事件
switch i{
case 0:
na.Triggered().Attach(wxdsInit)
case 1:
na.Triggered().Attach(wxdsToDrive)
case 2:
na.Triggered().Attach(wxdsToServer)
case 3:
na.Triggered().Attach(wxdsExplain)
}
// 将 子按钮 添加到 菜单
nm.Actions().Add(na)
}
//将菜单添加到托盘
sysmenu,err := ni.ContextMenu().Actions().AddMenu(nm)
if err != nil {
public.PrintLog(err)
}
// 主菜单 属性
sysmenu.SetText(fa)
sysmenu.SetVisible(true)
sysmenu.SetEnabled(true)
}
func wxdsInit(){
}
//--------------------------------------------------------------- //---------------------------------------------------------------
// //
// User Tools // User Tools
...@@ -232,7 +281,7 @@ func menuInitFileShares(ni * walk.NotifyIcon){ ...@@ -232,7 +281,7 @@ func menuInitFileShares(ni * walk.NotifyIcon){
wokrer := mem.Name() wokrer := mem.Name()
// 建立 子按钮 // 建立 子按钮
na := walk.NewAction() na := walk.NewAction()
if err := na.SetText(strings.TrimSuffix(wokrer,".lnk")); err != nil { if err := na.SetText(public.TrimSuffix(wokrer,".lnk")); err != nil {
public.PrintLog(err) public.PrintLog(err)
} }
...@@ -267,7 +316,7 @@ func menuInitFileShares(ni * walk.NotifyIcon){ ...@@ -267,7 +316,7 @@ func menuInitFileShares(ni * walk.NotifyIcon){
} }
func fsOpenWindow(s string){ func fsOpenWindow(s string){
public.PrintLog(s) public.PrintLog(s)
exec.Command("explorer",s).Start() public.Execcmd_nowait("explorer "+s)
} }
...@@ -336,7 +385,7 @@ func oJR_huyibo_movedisk(){ ...@@ -336,7 +385,7 @@ func oJR_huyibo_movedisk(){
public.SendDaemonExec(`F:\SamsungPortableSSD.exe`) public.SendDaemonExec(`F:\SamsungPortableSSD.exe`)
} }
func oRebootUser(){ func oRebootUser(){
public.Execcmd_nowait(public.Env_ADSoftTool_RebootUser) //public.Execcmd_nowait(public.Env_ADSoftTool_RebootUser)
} }
......
No preview for this file type
...@@ -15,6 +15,7 @@ func userInit(){ ...@@ -15,6 +15,7 @@ func userInit(){
func menuInit(ni * walk.NotifyIcon){ func menuInit(ni * walk.NotifyIcon){
menuInitPower(ni) menuInitPower(ni)
menuInitSoftwareInstall(ni) menuInitSoftwareInstall(ni)
menuInitWxDriveSync(ni)
menuInitUserTools(ni) menuInitUserTools(ni)
menuInitFileShares(ni) menuInitFileShares(ni)
menuInitOther(ni) menuInitOther(ni)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment