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
120e6a71
Commit
120e6a71
authored
May 27, 2020
by
陶腾飞
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
v0.9:新增微盘备份与同步功能,adct能够强制备份用户文件,用注册表来存储信息
parent
1345e69e
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
267 additions
and
86 deletions
+267
-86
.gitignore
+2
-0
README.MD
+5
-1
adct/adct.exe
+0
-0
adct/adct.go
+38
-3
daemon/daemon.exe
+0
-0
daemon/daemon.go
+10
-13
public/env.go
+35
-15
public/msg_deal.go
+44
-18
public/msg_init.go
+12
-5
public/public.go
+4
-0
public/send.go
+4
-3
public/time.go
+34
-0
public/win.go
+21
-0
users/menu.go
+49
-20
users/users.exe
+0
-0
users/users.go
+9
-8
No files found.
.gitignore
View file @
120e6a71
*.bat
*.ps1
/*test
/*.exe
\ No newline at end of file
README.MD
View file @
120e6a71
# AD-Control-Go
al
ng
# AD-Control-Go
la
ng
# 程序简介
本程序是从
[
AD-Control
](
http://git.zhiweidata.top/taotengfei/AD-Control
)
升级而来,并融合了在AD上经常使用的工具.
...
...
@@ -12,6 +12,7 @@
6.
**DCU,Domain Computer User**
是DC上的Users.exe用户进程
# 程序作用简要
## DCU - Domain Computer User
UI:在DC上以
**用户权限**
且
**任务栏托盘**
的方式运行
启动说明:由组策略的文件替换功能,从文件共享中复制到C:
\W
indows
\S
ystem32下,并运行
...
...
@@ -21,13 +22,16 @@ UI:在DC上以**用户权限**且**任务栏托盘**的方式运行
2.
软件安装
3.
微盘同步
4.
文件共享
## DCD - Domain Computer Daemon
运行方式:由组策略在计算机启动时运行命令
`runad.bat daemon`
来进行循环启动DCD。(
**管理员权限、无窗口**
)
主要功能运行由DCU和ADU提交的程序和与接受处理发送消息(通常处理需要管理员权限的消息)
## ADD - ADServer Daemon
运行方式:前后台任意
主要作用:根据ADU的参数设定响应来自DC端的请求
其他:使用注册表(HKLM
\S
oftware
\A
DControl)作为数据库的存储
## ADU - ADServer User(未完成)
运行方式: 命令行参数形式
主要作用:设定请求返回的结果
...
...
adct/adct.exe
View file @
120e6a71
No preview for this file type
adct/adct.go
View file @
120e6a71
...
...
@@ -3,7 +3,6 @@ import (
"AD-Control/public"
"time"
"flag"
_
"strings"
)
...
...
@@ -28,8 +27,44 @@ func main(){
return
}
func
flag_report
(
s
*
string
,
who
*
string
){
public
.
SendServer
(
public
.
GJreport
(
*
s
,
*
who
))
func
flag_report
(
s
*
string
,
user
*
string
){
switch
*
s
{
case
public
.
Msg_Report_UserStart
:
public
.
Reg_Write_DC
(
public
.
Reg_Name_loginUserName
,
*
user
)
public
.
Reg_Write_DC
(
public
.
Reg_Name_loginTime
,
public
.
GetStrTime
())
case
public
.
Msg_Report_StartBak
:
lastLoginUser
:=
public
.
Reg_Query_DC
(
public
.
Reg_Name_loginUserName
)
lastBackupUser
:=
public
.
Reg_Query_DC
(
public
.
Reg_Name_BackupUserName
)
lasttime
:=
public
.
Reg_Query_DC
(
public
.
Reg_Name_BackupOverTime
)
var
name
string
if
lastBackupUser
==
""
{
if
lastLoginUser
==
""
{
return
}
else
{
name
=
lastLoginUser
}
}
else
{
name
=
lastBackupUser
}
var
dt
public
.
DoTime
dt
.
Str
=
lasttime
// 如果不存在上次登录 或者 超过5小时备份时间
if
dt
.
BeforeHour
(
5
){
public
.
SendServer
(
public
.
GJreport
(
public
.
Msg_Report_StartBak
,
name
))
}
case
public
.
Msg_Report_OverBak
:
public
.
Reg_Write_DC
(
public
.
Reg_Name_loginUserName
,
*
user
)
public
.
Reg_Write_DC
(
public
.
Reg_Name_BackupOverTime
,
public
.
GetStrTime
())
}
public
.
SendServer
(
public
.
GJreport
(
*
s
,
*
user
))
}
func
flag_bakcup
(
s
*
string
){
;
...
...
daemon/daemon.exe
View file @
120e6a71
No preview for this file type
daemon/daemon.go
View file @
120e6a71
...
...
@@ -7,23 +7,20 @@ import (
"bufio"
)
//---------------------
//
// Daemon
//
//---------------------
// 守护进程 初始化
func
daemonInit
(){
if
public
.
NotExist
(
public
.
DocuBase
){
public
.
PrintLog
(
"init: create Documents Base -> "
,
public
.
DocuBase
)
public
.
Mkdir
(
public
.
DocuBase
)
// 1 创建文件夹
for
_
,
i
:=
range
public
.
User_Dir_Be
{
if
public
.
NotExist
(
i
){
public
.
Mkdir
(
i
)
}
}
public
.
PrintLog
(
public
.
Msg_Report_DaemonStart
)
if
adserver
()
{
//
1
初始化 微盘复制状态
//
2
初始化 微盘复制状态
public
.
CopyStatusWeDrive
=
make
(
map
[
string
]
bool
)
public
.
CopyStatusWeDrive
[
public
.
Zhiwei_Dept_HB
]
=
true
public
.
CopyStatusWeDrive
[
public
.
Zhiwei_Dept_LP
]
=
true
...
...
@@ -35,11 +32,12 @@ func daemonInit(){
public
.
CopyStatusWeDrive
[
public
.
Zhiwei_Dept_TECH
]
=
true
}
else
{
//
1
发送 Daemon Start
//
2
发送 Daemon Start
public
.
SendServerReport
(
public
.
Msg_Report_DaemonStart
)
}
}
// 守护进程 运行
func
deamonRun
(){
daemonHost
:=
public
.
User_computername
listener
,
err
:=
net
.
Listen
(
"tcp"
,
public
.
DaemonListen
)
...
...
@@ -83,7 +81,6 @@ func deamonRun(){
}
func
main
()
{
daemonInit
()
deamonRun
()
...
...
public/env.go
View file @
120e6a71
package
public
// app env ////////////////////////////////////////////////////////////////
//const Debug bool
// AD-Control env
const
DaemonPort
string
=
"16823"
const
DaemonListen
string
=
":"
+
DaemonPort
const
ADServerDaemon
string
=
Env_MainADHostname
+
DaemonListen
var
LocalDaemon
string
=
User_computername
+
DaemonListen
const
DocuBase
string
=
`C:\Users\Public\Documents\AD-Control\`
const
RandMax
int
=
60
const
Version
string
=
"0.
8
"
const
Version
string
=
"0.
9
"
const
Application
string
=
"AD-Control-Log"
...
...
@@ -27,13 +27,17 @@ var User_appdata string = GetEnv("appdata")
var
User_sid
string
=
Reg_query_key_one
(
HKCU
,
`Software\Microsoft\Windows\CurrentVersion\FileAssociations`
,
"UserSid"
)
var
User_sessionID
string
=
Reg_query_item_one
(
HKU
,
User_sid
+
`\Volatile Environment`
)
var
User_Dir_WeDrive
string
=
User_appdata
+
`\Tencent\WXWork\Data`
var
User_Dir_WeDrive
=
[
2
]
string
{
User_appdata
+
`\Tencent\WXWork\Data`
,
User_profile
+
`\Documents\WXWork`
}
const
User_Dir_DCSave
string
=
`D:\DomainUserBackup`
var
User_Die_WeDriveBackup
string
=
User_Dir_DCSave
+
`\`
+
User_name
+
`\WeDriveBackup`
var
User_Dir_Be
=
[
2
]
string
{
DocuBase
,
User_Die_WeDriveBackup
}
// win-computer env /////////////////////////////////////////////////////
const
Env_FreeFileSyncExe
string
=
`C:\Progra~2\zhiwei\FreeFileSync_10.22\FreeFileSync.exe`
// AD env ///////////////////////////////////////////////////////////
const
Env_MainADHostname
string
=
"ADSERVER"
...
...
@@ -43,17 +47,27 @@ const Env_ADMain string = Env_SMBAdserver + "ADMAIN"
var
Env_ADMainDept
string
=
Env_ADMain
+
`\`
+
User_dept_str
var
Env_ADMainDeptShare
string
=
Env_ADMain
+
`\`
+
User_dept_str
+
`\`
+
"部门共享"
const
Env_ADSoftlike
string
=
Env_ADSoft
+
`\`
+
"softlike"
const
Env_AD
Application
string
=
Env_ADSoft
+
`\`
+
"application"
+
`\`
const
Env_AD
SoftApplication
string
=
Env_ADSoft
+
`\`
+
"application"
+
`\`
const
Env_ADSoftTool
string
=
Env_ADSoft
+
`\`
+
"tools"
+
`\`
const
Env_ADSoftTool_RebootUser
string
=
Env_ADSoftTool
+
"upusers.bat"
const
Env_ADSoftOthTool
string
=
Env_ADSoft
+
`\`
+
`othtools\`
const
Env_ADsoftware_local
string
=
`F:\software\softlike\`
// application ////////////////////////////////////////////////////////////////
const
App_adct
string
=
Env_ADSoftApplication
+
"adct.exe"
const
App_MultiSplit
string
=
Env_ADSoftOthTool
+
"win_MultiSplit.exe"
//const App_MulitOpenPages string = Env_ADOtherTool + "MultiOpenPages.bat"
// AD User env ////////////////////////////////////////////////////////////////
const
AD_User_main_admin
string
=
"zhiweiadserver"
const
AD_User_tengfei
string
=
"tengfei"
const
AD_User_taotengfei
string
=
"taotengfei"
const
AD_User_huyibo
string
=
"huyibo"
const
AD_User_xuwenqiang
string
=
"xuwenqiang"
const
Zhiwei_Dept_HB
string
=
"HB"
...
...
@@ -83,21 +97,27 @@ const (
HKLM
HKU
)
const
Reg_Root_achome
int
=
HKLM
const
Reg_Path_achome
string
=
`SOFTWARE\ADControl`
const
Reg_Path_achome_dc
string
=
Reg_Path_achome
+
`\DomainComputer\`
// use for adserver,not for dc
const
Reg_Name_achome_dc_lastlogin
string
=
"LastLogin"
const
Reg_Name_achome_dc_lastclose
string
=
"CloseWindows"
const
Reg_Name_achome_dc_WeDriveDir
string
=
"WeDriveDir"
const
Reg_Root_ac
int
=
HKLM
const
Reg_Root_dc
int
=
HKCU
const
Reg_Path_home
string
=
`SOFTWARE\ADControl`
const
Reg_Path_home_dc
string
=
Reg_Path_home
+
`\DomainComputer\`
// use for adserver,not for dc
const
Reg_Name_TurnOnTime
string
=
"TurnOnTime"
const
Reg_Name_TurnOffTime
string
=
"TurnOffTime"
const
Reg_Name_loginUserName
string
=
"loginUser"
const
Reg_Name_loginTime
string
=
"loginTime"
const
Reg_Name_BackupUserName
string
=
"BackupUserName"
const
Reg_Name_BackupOverTime
string
=
"BackupOverTime"
const
Reg_Name_WeDriveDir
string
=
"WeDriveDir"
// reg value /////////////////////////////////////////////////////////////////
var
Reg_Value_WeDriveDir
string
=
Reg_query_key_one
(
HKCU
,
Reg_Path_
achome
,
Reg_Name_achome_dc
_WeDriveDir
)
var
Reg_Value_WeDriveDir
string
=
Reg_query_key_one
(
HKCU
,
Reg_Path_
home
,
Reg_Name
_WeDriveDir
)
// other env ///////////////////////////////////////////////////////////////
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 "
var
Dir_Windows
string
=
GetEnv
(
"windir"
)
+
`\`
...
...
public/msg_deal.go
View file @
120e6a71
...
...
@@ -33,10 +33,8 @@ func DealMsgEnter(ip string,msgtype string,unmsg []byte) []byte {
ret
=
pmsg
.
Msg_Deal
()
// 错误 消息
case
Msg_Error
:
SendWX
(
string
(
unmsg
))
return
nil
// var pmsg MJerror
// ParseJsonBody(unmsg,&pmsg)
// ret = pmsg.Msg_Deal()
}
return
JsonToByte
(
&
ret
)
...
...
@@ -56,28 +54,51 @@ func (rep *MJreport)Msg_Deal() interface{} {
case
Msg_Report_Offwork
:
return
GJbackup
()
case
Msg_Report_StartBak
:
return
GJbackup
()
case
Msg_Report_OverBak
:
SysMsgBox
(
rep
.
Computername
,
"备份结束"
)
Reg_Write_key_one
(
Reg_Root_ac
,
Reg_Path_home_dc
+
rep
.
Computername
,
Reg_Name_BackupUserName
,
UnixTimeParse
(
&
rep
.
Timestamp
))
Reg_Write_key_one
(
Reg_Root_ac
,
Reg_Path_home_dc
+
rep
.
Computername
,
Reg_Name_BackupOverTime
,
UnixTimeParse
(
&
rep
.
Timestamp
))
return
GJexecAck
(
Msg_Exec_CloseWindows
)
case
Msg_Report_CloseWindows
:
Reg_Write_key_one
(
Reg_Root_ac
home
,
Reg_Path_
ac
home_dc
+
rep
.
Computername
,
Reg_Name_
achome_dc_lastclos
e
,
Reg_Root_ac
,
Reg_Path_home_dc
+
rep
.
Computername
,
Reg_Name_
TurnOnTim
e
,
UnixTimeParse
(
&
rep
.
Timestamp
))
case
Msg_Report_DaemonStart
:
Reg_Write_key_one
(
Reg_Root_ac
home
,
Reg_Path_
ac
home_dc
+
rep
.
Computername
,
Reg_Name_
achome_dc_lastlogin
,
Reg_Root_ac
,
Reg_Path_home_dc
+
rep
.
Computername
,
Reg_Name_
TurnOffTime
,
UnixTimeParse
(
&
rep
.
Timestamp
))
case
Msg_Report_UserStart
:
if
rep
.
Version
!=
Version
{
return
GJexecAck
(
Msg_Exec_UpdateVersion
)
}
Reg_Write_key_one
(
Reg_Root_ac
,
Reg_Path_home_dc
+
rep
.
Computername
,
Reg_Name_loginUserName
,
rep
.
Username
)
Reg_Write_key_one
(
Reg_Root_ac
,
Reg_Path_home_dc
+
rep
.
Computername
,
Reg_Name_loginTime
,
UnixTimeParse
(
&
rep
.
Timestamp
))
case
Msg_Report_OverCopyToWeDrive
:
go
func
()
{
Delay
(
600
)
...
...
@@ -164,8 +185,11 @@ func (exec *MJexec)Msg_Deal()interface{}{
}
switch
exec
.
Instruction
{
case
Msg_Exec_GUIExec
:
PsExec_sdi
(
exec
.
Computername
,
exec
.
Command
,
exec
.
SessionID
)
case
Msg_Exec_CopyWeDrive
:
reg_Value_WeDriveDir
:=
Reg_query_key_one
(
HKCU
,
Reg_Path_
achome
,
Reg_Name_achome_dc
_WeDriveDir
)
reg_Value_WeDriveDir
:=
Reg_query_key_one
(
HKCU
,
Reg_Path_
home
,
Reg_Name
_WeDriveDir
)
cmd
:=
`cmd /c xcopy `
+
Env_ADMainDeptShare
+
" /D "
+
reg_Value_WeDriveDir
+
`\`
+
Zhiwei_WxDrive_Folder
+
" /S /T /E /C /y"
Execcmd_wait
(
cmd
)
...
...
@@ -181,6 +205,7 @@ func (exec *MJexec)Msg_Deal()interface{}{
func
(
bak
*
MJbackup
)
Msg_Deal
()
interface
{}{
switch
bak
.
Status
{
case
Msg_Backup_Status_Start
:
if
!
PrimaryUser
(
bak
.
Username
)
{
return
nil
}
...
...
@@ -243,7 +268,7 @@ func (bak * MJbackup)Msg_Deal() interface{}{
bak
.
Explain
=
"Backup Ready"
return
bak
case
Msg_Backup_Status_Run
:
SysMsgBox
(
bak
.
Computername
,
bak
.
Username
+
" 开始备份"
)
//
SysMsgBox(bak.Computername,bak.Username + " 开始备份")
PsExec_sd
(
bak
.
Computername
,
Env_FreeFileSyncExe
+
" "
+
bak
.
BatchFileName
)
}
return
nil
...
...
@@ -264,6 +289,7 @@ func (reg * MJreg)Msg_Deal() interface{}{
// 关于 error 错误 的 消息处理
func
(
err
*
MJerror
)
Msg_Deal
()
interface
{}{
return
nil
}
\ No newline at end of file
// func (err * MJerror)Msg_Deal() interface{}{
// return nil
// }
\ No newline at end of file
public/msg_init.go
View file @
120e6a71
...
...
@@ -19,14 +19,15 @@ const Msg_Error string = "error"
// msg report type ///////////////////////////////////////////////////////////
const
Msg_Report_DaemonStart
string
=
"Daemon
Start"
const
Msg_Report_UserStart
string
=
"User
Start"
const
Msg_Report_DaemonStart
string
=
"DaemonStart"
const
Msg_Report_UserStart
string
=
"UserStart"
const
Msg_Report_Offwork
string
=
"offwork"
const
Msg_Report_OverBak
string
=
"overbak"
const
Msg_Report_CloseWindows
string
=
"closewindows"
const
Msg_Report_OverCopyToWeDrive
string
=
"overcopytowedrive"
const
Msg_Report_OverCopyToDeptShare
string
=
"OverCopyToDeptShare"
const
Msg_Report_StartBak
string
=
"startbak"
const
Msg_Report_OverBak
string
=
"overbak"
// msg backup type //////////////////////////////////////////////////////////////
...
...
@@ -36,7 +37,6 @@ const Msg_Backup_Status_Continue string = "Continue"
const
Msg_Backup_Status_Run
string
=
"run"
const
Msg_Backup_Status_Error
string
=
msgerror
// msg exec type ////////////////////////////////////////////////////////////////
const
(
...
...
@@ -60,6 +60,7 @@ const Msg_Exec_UpdateVersion_cmd string = "Env_ADSoftTool_Update"
const
Msg_Exec_InstallSoftware
string
=
"installsoftware"
const
Msg_Exec_CopyWeDrive
string
=
"copyWeDrive"
const
Msg_Exec_CopyDeptShare
string
=
"copydeptshare"
const
Msg_Exec_GUIExec
string
=
"guiexec"
// msg error type ///////////////////////////////////////////////////////////////
...
...
@@ -190,6 +191,13 @@ func GJexecUserCmd(s string) interface{}{
exec
.
Status
=
Msg_Exec_State_Ack
return
exec
}
func
GJexecGUI
(
s
string
)
interface
{}{
var
exec
MJexec
exec
.
init
(
Msg_Exec_GUIExec
)
exec
.
Command
=
s
exec
.
Status
=
Msg_Exec_State_Ack
return
exec
}
func
(
exec
*
MJexec
)
init
(
s
string
){
exec
.
Dept
=
User_dept
exec
.
Username
=
User_name
...
...
@@ -217,7 +225,6 @@ func (bak * MJbackup)init() {
bak
.
MsgType
=
Msg_Backup
bak
.
Version
=
BackupVersion
bak
.
Status
=
Msg_Backup_Status_Start
bak
.
Version
=
Version
}
// error
...
...
public/public.go
View file @
120e6a71
...
...
@@ -204,3 +204,6 @@ func NowTimestamp() int64 {
func
UnixTimeParse
(
t
*
int64
)
string
{
return
time
.
Unix
(
*
t
,
0
)
.
String
()
}
func
GetStrTime
()
string
{
return
time
.
Now
()
.
String
()
}
\ No newline at end of file
public/send.go
View file @
120e6a71
...
...
@@ -12,8 +12,7 @@ import (
func
SendDaemon
(
v
interface
{})[]
byte
{
return
SendMsg
(
LocalDaemon
,
v
)
}
// func SendDaemonGuiExec(s stirng)
// SendDaemon()
func
SendDaemonExec
(
s
string
){
SendDaemon
(
GJexecUserCmd
(
s
))
}
...
...
@@ -23,7 +22,9 @@ func SendServerReport(s string)[]byte{
func
SendServerExec
(
s
string
)[]
byte
{
return
SendServer
(
GJexec
(
s
))
}
func
SendServerGUIExec
(
s
string
){
SendServer
(
GJexecGUI
(
s
))
}
func
SendServerError
(
s
string
)[]
byte
{
return
SendServer
(
GJerror
(
&
s
))
}
...
...
public/time.go
0 → 100644
View file @
120e6a71
package
public
import
(
"time"
)
// 关于 操作时间 的 结构体
type
DoTime
struct
{
Str
string
T
time
.
Time
}
// 判断 是否早于i小时
// 返回 是:早于i小时
// 返回 否:晚于i小时
func
(
dt
*
DoTime
)
base
(){
if
dt
.
Str
!=
""
{
time
.
Parse
(
"2020-05-24 17:06:47 +0800 CST"
,
dt
.
Str
)
}
}
func
(
dt
*
DoTime
)
BeforeHour
(
i
int
)
bool
{
var
err
error
if
dt
.
Str
!=
""
{
dt
.
T
,
err
=
time
.
Parse
(
"2006-01-02 15:04:05.999999999 -0700 MST"
,
dt
.
Str
)
if
err
!=
nil
{
PrintLog
(
err
)
return
false
}
}
if
dt
.
T
.
Add
(
time
.
Duration
(
5
)
*
time
.
Hour
)
.
Before
(
time
.
Now
()){
return
true
}
return
false
}
\ No newline at end of file
public/win.go
View file @
120e6a71
...
...
@@ -190,3 +190,23 @@ func Reg_Write_key_one(root int, path, name, value string) {
PrintLog
(
kerr
)
}
}
// func Reg_Write_AD(key , value * string){
// Reg_Write_key_one(
// Reg_Root_achome,
// Reg_Path_achome,
// *key,
// *value)
// }
func
Reg_Write_DC
(
key
,
value
string
){
Reg_Write_key_one
(
Reg_Root_dc
,
Reg_Path_home
,
key
,
value
)
}
func
Reg_Query_DC
(
key
string
)
string
{
return
Reg_query_key_one
(
Reg_Root_dc
,
Reg_Path_home
,
key
)
}
\ No newline at end of file
users/menu.go
View file @
120e6a71
...
...
@@ -61,6 +61,7 @@ func menuInitPower(ni * walk.NotifyIcon){
// 电源管理 下班
func
pWorkOff
(){
public
.
SendServerReport
(
public
.
Msg_Report_Offwork
)
}
// 电源管理 关机
func
pCloseWindows
(){
...
...
@@ -150,7 +151,7 @@ func siEnter_admin(softname string){
// 微盘同步
func
menuInitWxDriveSync
(
ni
*
walk
.
NotifyIcon
){
fa
:=
"微盘同步"
sub
:=
[
...
]
string
{
"初始化"
,
"同步部门共享盘到微盘(
手动)"
,
"同步部门共享盘到服务器(手
动)"
,
"说明"
}
sub
:=
[
...
]
string
{
"初始化"
,
"同步部门共享盘到微盘(
自动)"
,
"同步微盘部门共享文件到本地服务器(手动)"
,
"备份微盘非公共文件夹(自
动)"
,
"说明"
}
// 建立空菜单
nm
,
err
:=
walk
.
NewMenu
()
if
err
!=
nil
{
...
...
@@ -173,6 +174,8 @@ func menuInitWxDriveSync(ni * walk.NotifyIcon){
case
2
:
na
.
Triggered
()
.
Attach
(
wxdsToServer
)
case
3
:
na
.
Triggered
()
.
Attach
(
func
(){
wxdsToLocal
(
true
)})
case
4
:
na
.
Triggered
()
.
Attach
(
wxdsExplain
)
}
...
...
@@ -194,19 +197,22 @@ func menuInitWxDriveSync(ni * walk.NotifyIcon){
}
// 微盘同步 初始化
func
wxdsInit
(){
explain
:=
"选择个人ID,请根据微盘的文件夹所在位置进行选择,确定并选择并点击文件夹(一串数字)后,点击确定继续进行下一步!具体操作方法点击说明!"
initDir
:=
public
.
User_Dir_WeDrive
FullWeDrive
:=
public
.
ChooseFolder
(
&
explain
,
&
initDir
)
FullWeDrive
=
FullWeDrive
+
`\WeDrive\知微数据`
explain
:=
"选择个人ID(一般是168开头),请根据微盘的文件夹所在位置进行选择,确定并选择并点击文件夹(一串数字)后,点击确定继续进行下一步!具体操作方法点击说明!"
var
FullWeDrive
string
for
_
,
i
:=
range
public
.
User_Dir_WeDrive
{
if
public
.
Exist
(
i
+
`\Global`
){
FullWeDrive
=
public
.
ChooseFolder
(
&
explain
,
&
i
)
+
`\WeDrive\知微数据`
continue
}
}
public
.
PrintLog
(
FullWeDrive
)
if
public
.
NotExist
(
FullWeDrive
){
public
.
Msg
(
"不存在知微数据文件夹,请重新选择"
)
return
}
public
.
Reg_Write_key_one
(
public
.
HKCU
,
public
.
Reg_Path_achome
,
public
.
Reg_Name_achome_dc_WeDriveDir
,
public
.
Reg_Write_DC
(
public
.
Reg_Name_WeDriveDir
,
FullWeDrive
)
public
.
Msg
(
"初始化完毕,请在微盘中创建文件夹(办公室部门内部共享),并分享给同事,创建后,点击开始同步即可。"
)
}
...
...
@@ -215,25 +221,40 @@ func wxdsToDrive(){
if
public
.
Msg_YesNo
(
"确定手动进行一次 -> 从共享盘同步到微盘吗?如果调整过共享盘的文件结构,请先在微盘中同步调整,否则微盘将会混沌。"
)
==
1
{
public
.
SendServer
(
public
.
GJexecCopyWeDrive
(
public
.
Msg_Exec_CopyWeDrive
))
public
.
Msg
(
"同步完成!"
)
}
}
// 微盘同步 同步到服务器
func
wxdsToServer
(){
reg_Value_WeDriveDir
:=
public
.
Reg_query_key_one
(
public
.
HKCU
,
public
.
Reg_Path_achome
,
public
.
Reg_Name_achome_dc_WeDriveDir
)
reg_Value_WeDriveDir
:=
public
.
Reg_Query_DC
(
public
.
Reg_Name_WeDriveDir
)
weDrive_Share_Dir
:=
reg_Value_WeDriveDir
+
`\`
+
public
.
Zhiwei_WxDrive_Folder
if
reg_Value_WeDriveDir
!=
""
&&
public
.
Exist
(
weDrive_Share_Dir
){
if
public
.
Msg_YesNo
(
"确定手动进行一次 -> 从微盘到共享盘吗?如果俩者文件结构不一致,文件盘将会混沌。"
)
==
1
{
cmd
:=
`cmd /c xcopy `
+
weDrive_Share_Dir
+
" /D "
+
public
.
Env_ADMainDeptShare
+
" /S /T
/E /C /y"
cmd
:=
`cmd /c xcopy `
+
weDrive_Share_Dir
+
public
.
Env_ADMainDeptShare
+
"/D /S
/E /C /y"
public
.
Execcmd_wait
(
cmd
)
public
.
SendServerReport
(
public
.
Msg_Report_OverCopyToDeptShare
)
public
.
Msg
(
"同步完成!"
)
}
}
else
{
public
.
Msg
(
"未进行初始化或当前微盘路径错误,请重新初始化。微盘路径信息:"
+
reg_Value_WeDriveDir
)
}
}
// 微盘同步 备份微盘非公共文件到本地
func
wxdsToLocal
(
msgshow
bool
){
reg_Value_WeDriveDir
:=
public
.
Reg_Query_DC
(
public
.
Reg_Name_WeDriveDir
)
if
public
.
Exist
(
reg_Value_WeDriveDir
){
if
msgshow
{
public
.
Msg_YesNo
(
"确定手动进行一次 -> 备份微盘非公共文件到本地吗?没有副作用,也没有完成提醒!"
)
}
cmd
:=
`cmd /c xcopy `
+
reg_Value_WeDriveDir
+
" "
+
public
.
User_Die_WeDriveBackup
+
" /D /S /E /C /y"
public
.
PrintLog
(
cmd
)
public
.
SendDaemonExec
(
cmd
)
}
else
{
if
msgshow
{
public
.
Msg
(
"未进行初始化或当前微盘路径错误,请重新初始化。微盘路径信息:"
+
reg_Value_WeDriveDir
)
}
}
}
...
...
@@ -267,7 +288,7 @@ func wxdsExplain(){
func
menuInitTools
(
ni
*
walk
.
NotifyIcon
){
fa
:=
"工具集合"
sub
:=
[
...
]
string
{
"Excel关键词分割"
,
"隐藏桌面图标"
,
"显示桌面图标"
,
"移动硬盘"
,
"测试"
}
sub
:=
[
...
]
string
{
"Excel关键词分割"
,
"隐藏桌面图标"
,
"显示桌面图标"
,
"移动硬盘
(胡一波)"
,
"键盘驱动(许文强)
"
,
"测试"
}
// 建立空菜单
nm
,
err
:=
walk
.
NewMenu
()
if
err
!=
nil
{
...
...
@@ -278,8 +299,11 @@ func menuInitTools(ni * walk.NotifyIcon){
// 过滤按钮
switch
i
{
case
lastone
-
1
:
case
lastone
-
2
:
if
!
public
.
TheUser
(
public
.
AD_User_huyibo
)
{
continue
}
case
lastone
-
1
:
if
!
public
.
TheUser
(
public
.
AD_User_xuwenqiang
)
{
continue
}
case
lastone
:
if
!
public
.
AdminUser
()
{
continue
}
}
...
...
@@ -300,8 +324,10 @@ func menuInitTools(ni * walk.NotifyIcon){
na
.
Triggered
()
.
Attach
(
tShowIcon
)
case
lastone
-
2
:
na
.
Triggered
()
.
Attach
(
t_movedisk_huyibo
)
case
lastone
-
1
:
na
.
Triggered
()
.
Attach
(
t
JR_huyibo_movedisk
)
na
.
Triggered
()
.
Attach
(
t
_keyboard_xuwenqiang
)
case
lastone
:
na
.
Triggered
()
.
Attach
(
tTest
)
...
...
@@ -325,12 +351,15 @@ func menuInitTools(ni * walk.NotifyIcon){
}
// 其他工具 Excel关键词分割器
func
tMultiSplit
(){
public
.
Execcmd_nowait
(
public
.
Startk
+
public
.
Link
_MultiSplit
)
public
.
Execcmd_nowait
(
public
.
Startk
+
public
.
App
_MultiSplit
)
}
// 其他工具 移动硬盘(胡一波专用)
func
t
JR_huyibo_movedisk
(){
func
t
_movedisk_huyibo
(){
public
.
SendDaemonExec
(
`F:\SamsungPortableSSD.exe`
)
}
func
t_keyboard_xuwenqiang
(){
public
.
SendServerGUIExec
(
`start C:\Users\Public\Desktop\Durgod_Zeus_Engine.lnk`
)
}
// 其他工具 隐藏图标
func
tHideIcon
(){
public
.
Msg
(
"emmmmmmm,大概下周吧,这周无望哈"
)
...
...
users/users.exe
View file @
120e6a71
No preview for this file type
users/users.go
View file @
120e6a71
...
...
@@ -5,12 +5,13 @@ import (
"AD-Control/public"
)
func
userInit
()
string
{
public
.
Reg_Exist_item
(
public
.
HKCU
,
public
.
Reg_Path_
ac
home
)
public
.
Reg_Exist_item
(
public
.
HKCU
,
public
.
Reg_Path_home
)
// 1 同步服务器文件共享到为微盘
if
public
.
Reg_Value_WeDriveDir
!=
""
&&
public
.
Exist
(
public
.
Zhiwei_WxDrive_Full_Folder
){
// 如果微盘的文件夹存在
// 则,重复执行
// 随机延迟300s,进行复制,固定延迟2h
if
public
.
Reg_Value_WeDriveDir
!=
""
&&
public
.
Exist
(
public
.
Zhiwei_WxDrive_Full_Folder
){
go
func
(){
for
{
public
.
RandDelay
(
300
)
...
...
@@ -19,6 +20,11 @@ func userInit() string{
}
}()
}
// 2 备份微盘文件到本地
go
wxdsToLocal
(
false
)
// 3 初始化 图标文件
var
icoDir
=
[]
string
{
`AD-Control.ico`
,
`C:\windows\system32\AD-Control.ico`
,
`C:\Users\Public\Documents\AD-Control\AD-Control.ico`
}
for
_
,
i
:=
range
icoDir
{
if
public
.
Exist
(
i
){
...
...
@@ -26,6 +32,7 @@ func userInit() string{
}
}
public
.
SendServerError
(
"no icon file"
)
return
""
}
func
menuInit
(
ni
*
walk
.
NotifyIcon
){
...
...
@@ -42,8 +49,6 @@ func main() {
// 用户初始化
icodir
:=
userInit
()
public
.
PrintLog
(
icodir
)
// 程序初始化
mw
,
err
:=
walk
.
NewMainWindow
()
if
err
!=
nil
{
...
...
@@ -76,10 +81,6 @@ func main() {
public
.
PrintLog
(
err
)
}
// init over
public
.
SendServerReport
(
public
.
Msg_Report_UserStart
)
// 循环 运行窗体
mw
.
Run
()
}
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