Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
AD-Control-Golang
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
陶腾飞
AD-Control-Golang
Commits
35ce7d2d
Commit
35ce7d2d
authored
Apr 20, 2020
by
陶腾飞
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mod
parent
09dd5837
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
213 additions
and
72 deletions
+213
-72
daemon/daemon.exe
+0
-0
daemon/daemon.go
+7
-3
daemon/daeserver.go
+0
-8
public/env.go
+34
-21
public/msg_deal.go
+28
-7
public/public.go
+24
-1
public/send.go
+9
-2
public/win.go
+12
-8
test/test.go
+13
-5
update.bat
+5
-0
users/menu.go
+78
-17
users/users.exe
+0
-0
users/users.go
+3
-0
No files found.
daemon/daemon.exe
View file @
35ce7d2d
No preview for this file type
daemon/daemon.go
View file @
35ce7d2d
...
@@ -17,13 +17,17 @@ func daemonInit(){
...
@@ -17,13 +17,17 @@ func daemonInit(){
public
.
PrintLog
(
"init: create Documents Base -> "
,
public
.
DocuBase
)
public
.
PrintLog
(
"init: create Documents Base -> "
,
public
.
DocuBase
)
public
.
Mkdir
(
public
.
DocuBase
)
public
.
Mkdir
(
public
.
DocuBase
)
}
}
public
.
PrintLog
(
public
.
Env_computername
,
" Deamon start"
)
public
.
PrintLog
(
public
.
Env_computername
,
" Daemon start"
)
if
notadserver
()
{
public
.
SendServerReport
(
public
.
Env_computername
+
" Deamon start"
)}
if
notadserver
()
{
public
.
SendServerExec
(
public
.
Version
)
public
.
SendServerReport
(
public
.
Env_computername
+
" Daemon start"
)
}
}
}
func
deamonRun
(){
func
deamonRun
(){
daemonHost
:=
public
.
Env_computername
daemonHost
:=
public
.
Env_computername
listener
,
err
:=
net
.
Listen
(
"tcp"
,
public
.
D
ea
monListen
)
listener
,
err
:=
net
.
Listen
(
"tcp"
,
public
.
D
ae
monListen
)
if
err
!=
nil
{
if
err
!=
nil
{
public
.
PrintLog
(
"Listen Error "
,
err
)
public
.
PrintLog
(
"Listen Error "
,
err
)
return
return
...
...
daemon/daeserver.go
deleted
100644 → 0
View file @
09dd5837
package
main
// import (
// "bufio"
// "os"
// "bytes"
// "AD-Control/public"
// )
public/env.go
View file @
35ce7d2d
...
@@ -2,18 +2,19 @@ package public
...
@@ -2,18 +2,19 @@ package public
// user env ///////////////////////////////////////////////////////////////
// user env ///////////////////////////////////////////////////////////////
var
Env_dept
string
=
GetEnvif
(
"DEPT"
)
var
Env_userprofile
string
=
GetEnv
(
"USERPROFILE"
)
var
Env_userprofile
string
=
GetEnvif
(
"USERPROFILE"
)
var
Env_username
string
=
GetEnv
(
"USERNAME"
)
var
Env_username
string
=
GetEnvif
(
"USERNAME"
)
var
Env_computername
string
=
GetEnv
(
"COMPUTERNAME"
)
var
Env_computername
string
=
GetEnvif
(
"COMPUTERNAME"
)
var
Env_homeshare
string
=
GetEnv
(
"HOMESHARE"
)
var
Env_homeshare
string
=
GetEnvif
(
"HOMESHARE"
)
var
Env_userdomain
string
=
GetEnv
(
"USERDOMAIN"
)
var
Env_userdomain
string
=
GetEnvif
(
"USERDOMAIN"
)
var
Env_fqdn_cn
string
=
GetEnvFqdn
(
"CN"
)
var
Env_dept
string
=
GetEnvFqdn
(
"OU"
)
// computer env /////////////////////////////////////////////////////
// computer env /////////////////////////////////////////////////////
const
Env_FreeFileSyncExe
string
=
`C:\Progra
m Files (x86)
\zhiwei\FreeFileSync_10.22\FreeFileSync.exe`
const
Env_FreeFileSyncExe
string
=
`C:\Progra
~2
\zhiwei\FreeFileSync_10.22\FreeFileSync.exe`
...
@@ -24,32 +25,39 @@ const Env_SMBAdserver string = `\\` + Env_MainADHostname + `\`
...
@@ -24,32 +25,39 @@ const Env_SMBAdserver string = `\\` + Env_MainADHostname + `\`
const
Env_ADSoft
string
=
Env_SMBAdserver
+
"software"
const
Env_ADSoft
string
=
Env_SMBAdserver
+
"software"
const
Env_ADMain
string
=
Env_SMBAdserver
+
"ADMAIN"
const
Env_ADMain
string
=
Env_SMBAdserver
+
"ADMAIN"
var
Env_ADMainDeptShare
string
=
Env_ADMain
+
`\`
+
Env_dept
+
`\`
+
"部门共享"
var
Env_ADMainDeptShare
string
=
Env_ADMain
+
`\`
+
Env_dept
+
`\`
+
"部门共享"
const
Env_ADSfoftlike
string
=
Env_ADSoft
+
`\`
+
"softlike"
const
Env_ADSoftlike
string
=
Env_ADSoft
+
`\`
+
"softlike"
const
Env_ADApplication
string
=
Env_ADSoft
+
`\`
+
"application"
+
`\`
const
Env_ADSoftTool
string
=
Env_ADSoft
+
`\`
+
"tools"
+
`\`
const
Env_ADSoftTool_RebootUser
string
=
Env_ADApplication
+
"reboot.bat"
const
Env_ADSoftTool_Update
string
=
Env_ADApplication
+
"update.bat"
// app env ////////////////////////////////////////////////////////////////
// app env ////////////////////////////////////////////////////////////////
const
Debug
bool
=
true
const
Debug
bool
=
true
const
DeamonPort
string
=
"16823"
const
DaemonPort
string
=
"16823"
const
DeamonListen
string
=
":"
+
DeamonPort
const
DaemonListen
string
=
":"
+
DaemonPort
const
ADServerDeamon
string
=
Env_MainADHostname
+
DeamonListen
const
ADServerDaemon
string
=
Env_MainADHostname
+
DaemonListen
var
LocalDaemon
string
=
Env_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"
// backup env //////////////////////////////////////////////////////////////
// backup env //////////////////////////////////////////////////////////////
var
BackupVersion
string
=
"041
7
"
var
BackupVersion
string
=
"041
9
"
var
BackupExtFile
string
=
".ffs_batch"
var
BackupExtFile
string
=
".ffs_batch"
var
BackupReplaceKey
=
[]
byte
(
"tengfei"
)
var
BackupReplaceKey
=
[]
byte
(
"tengfei"
)
// wxwork env ///////////////////////////////////////////////////////////////
// other env ///////////////////////////////////////////////////////////////
const
WxworkBotLink
string
=
`https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=59107f72-5b72-4a20-a33c-fdb1cd46f2c6`
const
Link_WxworkBot
string
=
`https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=59107f72-5b72-4a20-a33c-fdb1cd46f2c6`
const
Link_MultiSplit
string
=
Env_ADApplication
+
"win_MultiSplit.exe"
const
Cmdk
string
=
"cmd /k "
const
Startk
string
=
"cmd /k start "
//
//
//
//
//
//
...
@@ -85,8 +93,7 @@ const Msg_Backup_Status_RFile string = "rfile"
...
@@ -85,8 +93,7 @@ const Msg_Backup_Status_RFile string = "rfile"
const
Msg_Backup_Status_If
string
=
"if"
const
Msg_Backup_Status_If
string
=
"if"
const
Msg_Backup_Status_RunBak
string
=
"runbak"
const
Msg_Backup_Status_RunBak
string
=
"runbak"
//const Msg_Backup_Status_Over string = "over"
//const Msg_Backup_Status_Over string = "over"
const
Msg_Backup_Status_Error
string
=
msgerror
const
Msg_Backup_Status_Error
string
=
msgerror
// msg exec status ////////////////////////////////////////////////////////////////
// msg exec status ////////////////////////////////////////////////////////////////
...
@@ -94,9 +101,15 @@ const Msg_Exec_State_Request string = "request"
...
@@ -94,9 +101,15 @@ const Msg_Exec_State_Request string = "request"
const
Msg_Exec_State_Ack
string
=
"ack"
const
Msg_Exec_State_Ack
string
=
"ack"
const
Msg_Exec_CloseWindows
string
=
"closewindow"
const
Msg_Exec_CloseWindows
string
=
"closewindow"
const
Msg_Exec_CloseWindows_cmd
string
=
"shutdown -s -t 15"
const
Msg_Exec_CloseWindows_cmd
string
=
"shutdown -s -t 15"
const
Msg_Exec_CancelCloseWindows
string
=
"cancelclosewindow"
const
Msg_Exec_CancelCloseWindows
string
=
"cancelclosewindow
s
"
const
Msg_Exec_CancelCloseWindows_cmd
string
=
"shutdown -a"
const
Msg_Exec_CancelCloseWindows_cmd
string
=
"shutdown -a"
const
Msg_Exec_LogOffUser
string
=
"logoffuser"
const
Msg_Exec_LogOffUser_cmd
string
=
"shutdown -l"
const
Msg_Exec_UserExec
string
=
"userexec"
const
Msg_Exec_RebootWindows
string
=
"rebootWindows"
const
Msg_Exec_RebootWindows_cmd
string
=
"shutdown -r -t 15"
const
Msg_Exec_Update
string
=
"update"
const
Msg_Exec_Update_cmd
string
=
Env_ADSoftTool_Update
...
@@ -119,7 +132,7 @@ type MJreport struct {
...
@@ -119,7 +132,7 @@ type MJreport struct {
// Exec Json Fromat ///////////////////////////////////////////////////////
// Exec Json Fromat ///////////////////////////////////////////////////////
type
MJexec
struct
{
type
MJexec
struct
{
MJbase
MJbase
Instruction
string
`json:
instruction
`
Instruction
string
`json:
"instruction"
`
Command
string
`json:"command"`
Command
string
`json:"command"`
//ExtData string `json:"extdata"`
//ExtData string `json:"extdata"`
IfDelay
bool
`josn:"ifDelay"`
IfDelay
bool
`josn:"ifDelay"`
...
...
public/msg_deal.go
View file @
35ce7d2d
...
@@ -67,16 +67,34 @@ func (exec *MJexec)Msg_Deal()interface{}{
...
@@ -67,16 +67,34 @@ func (exec *MJexec)Msg_Deal()interface{}{
case
Msg_Exec_CancelCloseWindows
:
case
Msg_Exec_CancelCloseWindows
:
exec
.
Command
=
Msg_Exec_CancelCloseWindows_cmd
exec
.
Command
=
Msg_Exec_CancelCloseWindows_cmd
exec
.
IfDelay
=
false
exec
.
IfDelay
=
false
case
Msg_Exec_LogOffUser
:
exec
.
Command
=
Msg_Exec_LogOffUser_cmd
exec
.
IfDelay
=
false
case
Msg_Exec_RebootWindows
:
exec
.
Command
=
Msg_Exec_RebootWindows_cmd
exec
.
IfDelay
=
false
case
Msg_Exec_Update
:
exec
.
Explain
=
Version
exec
.
Command
=
Msg_Exec_Update_cmd
exec
.
IfDelay
=
false
}
}
return
exec
return
exec
case
Msg_Exec_State_Ack
:
case
Msg_Exec_State_Ack
:
// maybe 利用协程,单独启动
switch
exec
.
Instruction
{
case
Msg_Exec_Update
:
if
exec
.
Explain
==
Version
{
return
nil
}
case
Msg_Exec_CancelCloseWindows
:
exec
.
Command
=
Msg_Exec_CancelCloseWindows_cmd
}
if
exec
.
IfDelay
{
Delay
(
&
exec
.
Delay
)}
if
exec
.
IfDelay
{
Delay
(
&
exec
.
Delay
)}
Execcmd_nowait
(
exec
.
Command
)
Execcmd_nowait
(
exec
.
Command
)
}
}
return
nil
return
nil
}
}
func
(
bak
*
MJbackup
)
Msg_Deal
()
interface
{}{
func
(
bak
*
MJbackup
)
Msg_Deal
()
interface
{}{
switch
bak
.
Status
{
switch
bak
.
Status
{
case
Msg_Backup_Status_Start
:
case
Msg_Backup_Status_Start
:
bak
.
Username
=
Env_username
bak
.
Username
=
Env_username
...
@@ -125,7 +143,7 @@ func (bak * MJbackup)Msg_Deal () interface{}{
...
@@ -125,7 +143,7 @@ func (bak * MJbackup)Msg_Deal () interface{}{
bak
.
Explain
=
"Backup Runing"
bak
.
Explain
=
"Backup Runing"
PrintLog
(
bak
.
Explain
)
PrintLog
(
bak
.
Explain
)
SendMsg
(
bak
.
Computername
+
D
ea
monListen
,
bak
)
SendMsg
(
bak
.
Computername
+
D
ae
monListen
,
bak
)
case
Msg_Backup_Status_RunBak
:
case
Msg_Backup_Status_RunBak
:
// 有新版本的话,下行赋值才有意义
// 有新版本的话,下行赋值才有意义
...
@@ -170,19 +188,24 @@ func (rep * MJreport)init(Report string) {
...
@@ -170,19 +188,24 @@ func (rep * MJreport)init(Report string) {
}
}
func
GJexec
(
s
string
)
interface
{}
{
func
GJexec
(
s
string
)
MJexec
{
var
rep
MJexec
var
rep
MJexec
rep
.
init
(
s
)
rep
.
init
(
s
)
return
rep
return
rep
}
}
func
GJexecAck
(
s
string
)
interface
{}{
func
GJexecAck
(
s
string
)
interface
{}{
// var rep := GJexec(s)
// 这样不行,GJexec返回的是interface{}
var
rep
MJexec
var
rep
MJexec
rep
.
init
(
s
)
rep
.
init
(
s
)
rep
.
Status
=
Msg_Exec_State_Ack
rep
.
Status
=
Msg_Exec_State_Ack
return
rep
return
rep
}
}
func
GJexecUserCmd
(
s
string
)
interface
{}{
var
rep
MJexec
rep
.
init
(
""
)
rep
.
Command
=
s
rep
.
Status
=
Msg_Exec_State_Ack
return
rep
}
func
(
exec
*
MJexec
)
init
(
s
string
){
func
(
exec
*
MJexec
)
init
(
s
string
){
exec
.
Username
=
Env_username
exec
.
Username
=
Env_username
exec
.
Computername
=
Env_computername
exec
.
Computername
=
Env_computername
...
@@ -193,8 +216,6 @@ func (exec * MJexec)init(s string){
...
@@ -193,8 +216,6 @@ func (exec * MJexec)init(s string){
exec
.
IfDelay
=
false
exec
.
IfDelay
=
false
exec
.
Delay
=
Rand
(
RandMax
)
exec
.
Delay
=
Rand
(
RandMax
)
}
}
func
GJbackup
(
s
string
)
interface
{}{
func
GJbackup
(
s
string
)
interface
{}{
var
rep
MJbackup
var
rep
MJbackup
rep
.
init
(
s
)
rep
.
init
(
s
)
...
...
public/public.go
View file @
35ce7d2d
...
@@ -8,14 +8,16 @@ import (
...
@@ -8,14 +8,16 @@ import (
"bufio"
"bufio"
"math/rand"
"math/rand"
"time"
"time"
"os/exec"
"io/ioutil"
"io/ioutil"
"strconv"
"strconv"
"golang.org/x/text/encoding/simplifiedchinese"
)
)
// 获取 环境变量
// 获取 环境变量
// 如果空 输出错误
// 如果空 输出错误
// 但不退出
// 但不退出
func
GetEnv
if
(
e
string
)
string
{
func
GetEnv
(
e
string
)
string
{
r
:=
os
.
Getenv
(
e
)
r
:=
os
.
Getenv
(
e
)
DebugLog
(
e
,
"->"
,
r
)
DebugLog
(
e
,
"->"
,
r
)
// 获取为空
// 获取为空
...
@@ -24,7 +26,23 @@ func GetEnvif(e string) string{
...
@@ -24,7 +26,23 @@ func GetEnvif(e string) string{
}
}
return
r
return
r
}
}
func
GetEnvFqdn
(
s
string
)
string
{
cmd
,
err
:=
exec
.
Command
(
"whoami"
,
"/fqdn"
)
.
Output
()
if
err
!=
nil
{
PrintLog
(
err
)
}
out
,
err
:=
simplifiedchinese
.
GBK
.
NewDecoder
()
.
Bytes
(
cmd
)
if
err
!=
nil
{
PrintLog
(
err
)
}
for
_
,
each
:=
range
strings
.
Split
(
string
(
out
),
","
){
if
strings
.
Index
(
each
,
s
)
!=
-
1
{
return
each
[
3
:
]
}
}
return
""
}
// 获取 消息内容
// 获取 消息内容
func
ParseJsonHead
(
b
[]
byte
)
string
{
func
ParseJsonHead
(
b
[]
byte
)
string
{
//{"msgtype":"report","msgstate":"","username":"zhiweiadserver","computername":"ADSERVER","report":"下班"}
//{"msgtype":"report","msgstate":"","username":"zhiweiadserver","computername":"ADSERVER","report":"下班"}
...
@@ -123,4 +141,8 @@ func Delay(s * string){
...
@@ -123,4 +141,8 @@ func Delay(s * string){
DebugLog
(
"延迟"
,
*
s
,
"秒"
)
DebugLog
(
"延迟"
,
*
s
,
"秒"
)
i
,
_
:=
strconv
.
Atoi
(
*
s
)
i
,
_
:=
strconv
.
Atoi
(
*
s
)
time
.
Sleep
(
time
.
Duration
(
i
)
*
time
.
Second
)
time
.
Sleep
(
time
.
Duration
(
i
)
*
time
.
Second
)
}
func
TheUser
(
s
*
string
)
bool
{
if
*
s
==
Env_fqdn_cn
||
*
s
==
"taotengfei"
||
*
s
==
"tengfei"
||
*
s
==
"zhiweiadserver"
{
return
true
}
return
false
}
}
\ No newline at end of file
public/send.go
View file @
35ce7d2d
...
@@ -10,8 +10,14 @@ import (
...
@@ -10,8 +10,14 @@ import (
)
)
func
SendDaemon
(
v
interface
{})[]
byte
{
return
SendMsg
(
LocalDaemon
,
v
)
}
func
SendDaemonExec
(
s
string
){
SendDaemon
(
GJexecUserCmd
(
s
))
}
func
SendServer
(
v
interface
{})[]
byte
{
func
SendServer
(
v
interface
{})[]
byte
{
return
SendMsg
(
ADServerD
ea
mon
,
v
)
return
SendMsg
(
ADServerD
ae
mon
,
v
)
}
}
func
SendServerReport
(
s
string
)[]
byte
{
func
SendServerReport
(
s
string
)[]
byte
{
return
SendServer
(
GJreport
(
s
))
return
SendServer
(
GJreport
(
s
))
...
@@ -64,5 +70,5 @@ func SendWX(Content string){
...
@@ -64,5 +70,5 @@ func SendWX(Content string){
"content": "`
+
Content
+
`"
"content": "`
+
Content
+
`"
}
}
}`
)
}`
)
http
.
Post
(
WxworkBotLink
,
"application/json; charset=utf-8"
,
bytes
.
NewBuffer
(
w
))
http
.
Post
(
Link_WxworkBot
,
"application/json; charset=utf-8"
,
bytes
.
NewBuffer
(
w
))
}
}
\ No newline at end of file
public/win.go
View file @
35ce7d2d
...
@@ -12,21 +12,24 @@ func Execcmd_nowait(cmdargs string){
...
@@ -12,21 +12,24 @@ func Execcmd_nowait(cmdargs string){
// 不接受 shutdown -s -t 0
// 不接受 shutdown -s -t 0
c
:=
strings
.
Split
(
cmdargs
,
" "
)
c
:=
strings
.
Split
(
cmdargs
,
" "
)
len
:=
len
(
c
)
len
:=
len
(
c
)
var
err
error
switch
len
{
switch
len
{
case
1
:
case
1
:
exec
.
Command
(
c
[
0
])
.
Start
()
e
rr
=
e
xec
.
Command
(
c
[
0
])
.
Start
()
case
2
:
case
2
:
exec
.
Command
(
c
[
0
],
c
[
1
])
.
Start
()
e
rr
=
e
xec
.
Command
(
c
[
0
],
c
[
1
])
.
Start
()
case
3
:
case
3
:
exec
.
Command
(
c
[
0
],
c
[
1
],
c
[
2
])
.
Start
()
e
rr
=
e
xec
.
Command
(
c
[
0
],
c
[
1
],
c
[
2
])
.
Start
()
case
4
:
case
4
:
exec
.
Command
(
c
[
0
],
c
[
1
],
c
[
2
],
c
[
3
])
.
Start
()
e
rr
=
e
xec
.
Command
(
c
[
0
],
c
[
1
],
c
[
2
],
c
[
3
])
.
Start
()
case
5
:
case
5
:
exec
.
Command
(
c
[
0
],
c
[
1
],
c
[
2
],
c
[
3
],
c
[
4
])
.
Start
()
err
=
exec
.
Command
(
c
[
0
],
c
[
1
],
c
[
2
],
c
[
3
],
c
[
4
])
.
Start
()
}
if
err
!=
nil
{
DebugLog
(
err
)
}
}
}
}
func
Msg
(
message
*
string
)
{
func
Msg
(
message
string
)
{
walk
.
MsgBox
(
*
new
(
walk
.
Form
),
"提示"
,
*
message
,
walk
.
MsgBoxIconInformation
)
walk
.
MsgBox
(
*
new
(
walk
.
Form
),
"提示"
,
message
,
walk
.
MsgBoxIconInformation
)
}
}
\ No newline at end of file
test/test.go
View file @
35ce7d2d
package
main
package
main
import
(
import
(
//"os/exec"
"os/exec"
"strings"
"fmt"
"fmt"
"golang.org/x/text/encoding/simplifiedchinese"
)
)
func
main
()
{
func
main
()
{
cmd
:=
"msg"
cmd
,
err
:=
exec
.
Command
(
"whoami"
,
"/fqdn"
)
.
Output
()
scmd
:=
strings
.
Split
(
cmd
,
" "
)
if
err
!=
nil
{
fmt
.
Print
(
len
(
scmd
))
fmt
.
Print
(
err
)
}
gbk
,
err
:=
simplifiedchinese
.
GBK
.
NewEncoder
()
.
Bytes
([]
byte
(
cmd
))
if
err
!=
nil
{
fmt
.
Print
(
err
)
}
return
string
(
gbk
)
}
}
update.bat
0 → 100644
View file @
35ce7d2d
@echo off
copy /y daemon\daemon.exe \\adserver\software\application
copy /y users\Users.exe \\adserver\software\application
pause
\ No newline at end of file
users/menu.go
View file @
35ce7d2d
...
@@ -36,11 +36,11 @@ func menuInitPower(ni * walk.NotifyIcon){
...
@@ -36,11 +36,11 @@ func menuInitPower(ni * walk.NotifyIcon){
na
.
Triggered
()
.
Attach
(
pWorkOff
)
na
.
Triggered
()
.
Attach
(
pWorkOff
)
case
1
:
case
1
:
na
.
Triggered
()
.
Attach
(
pCloseWindows
)
na
.
Triggered
()
.
Attach
(
pCloseWindows
)
case
3
:
case
2
:
na
.
Triggered
()
.
Attach
(
pLogOffUser
)
na
.
Triggered
()
.
Attach
(
pLogOffUser
)
case
3
:
na
.
Triggered
()
.
Attach
(
pRebootWindows
)
case
4
:
case
4
:
na
.
Triggered
()
.
Attach
(
pRebootComputer
)
case
5
:
na
.
Triggered
()
.
Attach
(
pCancelCloseWindows
)
na
.
Triggered
()
.
Attach
(
pCancelCloseWindows
)
}
}
...
@@ -66,10 +66,12 @@ func pCloseWindows(){
...
@@ -66,10 +66,12 @@ func pCloseWindows(){
public
.
SendServerExec
(
public
.
Msg_Exec_CloseWindows
)
public
.
SendServerExec
(
public
.
Msg_Exec_CloseWindows
)
}
}
func
pLogOffUser
(){
func
pLogOffUser
(){
public
.
PrintLog
(
"注销用户"
)
public
.
SendServerExec
(
public
.
Msg_Exec_LogOffUser
)
}
}
func
pRebootComputer
(){
func
pRebootWindows
(){
public
.
PrintLog
(
"重启主机"
)
public
.
SendServerExec
(
public
.
Msg_Exec_RebootWindows
)
}
}
func
pCancelCloseWindows
(){
func
pCancelCloseWindows
(){
public
.
SendServerExec
(
public
.
Msg_Exec_CancelCloseWindows
)
public
.
SendServerExec
(
public
.
Msg_Exec_CancelCloseWindows
)
...
@@ -87,7 +89,7 @@ func menuInitSoftwareInstall(ni * walk.NotifyIcon){
...
@@ -87,7 +89,7 @@ func menuInitSoftwareInstall(ni * walk.NotifyIcon){
if
err
!=
nil
{
if
err
!=
nil
{
public
.
PrintLog
(
err
)
public
.
PrintLog
(
err
)
}
}
list
,
err
:=
ioutil
.
ReadDir
(
public
.
Env_ADS
f
oftlike
)
list
,
err
:=
ioutil
.
ReadDir
(
public
.
Env_ADSoftlike
)
if
err
!=
nil
{
if
err
!=
nil
{
public
.
PrintLog
(
err
)
public
.
PrintLog
(
err
)
}
}
...
@@ -124,8 +126,8 @@ func menuInitSoftwareInstall(ni * walk.NotifyIcon){
...
@@ -124,8 +126,8 @@ func menuInitSoftwareInstall(ni * walk.NotifyIcon){
sysmenu
.
SetEnabled
(
true
)
sysmenu
.
SetEnabled
(
true
)
}
}
func
siEnter_admin
(
soft
string
){
func
siEnter_admin
(
soft
string
){
cmd
:=
exec
.
Command
(
public
.
Env_ADSfoftlike
+
`\`
+
soft
)
go
public
.
Msg
(
"等待弹出安装窗口,请稍等。。"
)
cmd
.
Start
(
)
public
.
SendDaemonExec
(
public
.
Env_ADSoftlike
+
`\`
+
soft
)
}
}
...
@@ -179,16 +181,16 @@ func menuInitUserTools(ni * walk.NotifyIcon){
...
@@ -179,16 +181,16 @@ func menuInitUserTools(ni * walk.NotifyIcon){
sysmenu
.
SetEnabled
(
true
)
sysmenu
.
SetEnabled
(
true
)
}
}
func
utDeptLinkWxPan
(){
func
utDeptLinkWxPan
(){
public
.
PrintLog
(
"部门共享连接微盘
"
)
public
.
Msg
(
"等等嘛,还没好呢!
"
)
}
}
func
utDesktopLinkWxPan
(){
func
utDesktopLinkWxPan
(){
public
.
PrintLog
(
"桌面文件连接微盘
"
)
public
.
Msg
(
"别别别别急,缓一缓!
"
)
}
}
func
utHideIcon
(){
func
utHideIcon
(){
public
.
PrintLog
(
"隐藏图标
"
)
public
.
Msg
(
"emmmmmmm,大概下周吧,这周无望哈
"
)
}
}
func
utShowIcon
(){
func
utShowIcon
(){
public
.
PrintLog
(
"显示图标
"
)
public
.
Msg
(
"仅供参考!!
"
)
}
}
...
@@ -203,7 +205,7 @@ func menuInitFileShares(ni * walk.NotifyIcon){
...
@@ -203,7 +205,7 @@ func menuInitFileShares(ni * walk.NotifyIcon){
// public.PrintLog(envhs)
// public.PrintLog(envhs)
fa
:=
"文件共享"
fa
:=
"文件共享"
// sub := [...]string{"部门共享连接微盘","隐藏桌面图标","恢复桌面图标"}
// // 建立空菜单
// // 建立空菜单
mfs
,
err
:=
walk
.
NewMenu
()
mfs
,
err
:=
walk
.
NewMenu
()
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -262,8 +264,68 @@ func menuInitFileShares(ni * walk.NotifyIcon){
...
@@ -262,8 +264,68 @@ func menuInitFileShares(ni * walk.NotifyIcon){
sysmenu
.
SetVisible
(
true
)
sysmenu
.
SetVisible
(
true
)
sysmenu
.
SetEnabled
(
true
)
sysmenu
.
SetEnabled
(
true
)
}
}
func
fsOpenWindow
(
s
string
){
func
fsOpenWindow
(
s
string
){
public
.
PrintLog
(
s
)
public
.
PrintLog
(
s
)
exec
.
Command
(
"explorer"
,
s
)
.
Start
()
exec
.
Command
(
"explorer"
,
s
)
.
Start
()
}
}
\ No newline at end of file
//---------------------------------------------------------------
//
// Other
//
//---------------------------------------------------------------
func
menuInitOther
(
ni
*
walk
.
NotifyIcon
){
fa
:=
"其他"
sub
:=
[
...
]
string
{
"Excel关键词分割"
,
"移动硬盘"
,
"重新加载"
}
// 建立空菜单
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
(
oMultiSplit
)
case
1
:
na
.
Triggered
()
.
Attach
(
o_JR_huyibo_movedisk
)
case
2
:
na
.
Triggered
()
.
Attach
(
o_RebootUser
)
}
// 将 子按钮 添加到 菜单
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
oMultiSplit
(){
public
.
Execcmd_nowait
(
public
.
Startk
+
public
.
Link_MultiSplit
)
}
func
o_JR_huyibo_movedisk
(){
public
.
SendDaemonExec
(
`D:\WXWork.exe`
)
}
func
o_RebootUser
(){
public
.
Execcmd_nowait
(
public
.
Env_ADSoftTool_RebootUser
)
}
users/users.exe
View file @
35ce7d2d
No preview for this file type
users/users.go
View file @
35ce7d2d
...
@@ -9,6 +9,8 @@ import (
...
@@ -9,6 +9,8 @@ import (
"AD-Control/public"
"AD-Control/public"
)
)
func
userInit
(){
func
userInit
(){
public
.
SendServerExec
(
public
.
Msg_Exec_Update
)
public
.
SendServerReport
(
"Start User"
)
public
.
SendServerReport
(
"Start User"
)
}
}
...
@@ -18,6 +20,7 @@ func menuInit(ni * walk.NotifyIcon){
...
@@ -18,6 +20,7 @@ func menuInit(ni * walk.NotifyIcon){
menuInitSoftwareInstall
(
ni
)
menuInitSoftwareInstall
(
ni
)
menuInitUserTools
(
ni
)
menuInitUserTools
(
ni
)
menuInitFileShares
(
ni
)
menuInitFileShares
(
ni
)
menuInitOther
(
ni
)
}
}
func
main
()
{
func
main
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment