CHEATSHEET January 19, 2022

windows

Words count 21k Reading time 19 mins. Read count 0

本机外网ip

windows/linux通用

1
2
3
4
5
6
curl ip.sb # 只显示ipv4

curl cip.cc #显示ipv4和地址信息

# 指定ip信息
curl ifconfig.me/ip --resolve 'ifconfig.me:80:34.117.118.44'

进程参数

1
2
3
4
tasklist|findstr 21692
wmic process get caption,commandline /value |findStr mstsc
wmic process where caption="cmd.exe" get caption,commandline /value
wmic process where caption="xshell.exe" get caption,commandline /value

开关wifi

netsh interface set interface “WLAN” enabled
netsh interface set interface “WLAN” disabled

开关热点

HotspotOnOff.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
[Windows.System.UserProfile.LockScreen,Windows.System.UserProfile,ContentType=WindowsRuntime] | Out-Null
Add-Type -AssemblyName System.Runtime.WindowsRuntime
$asTaskGeneric = ([System.WindowsRuntimeSystemExtensions].GetMethods() | ? { $_.Name -eq 'AsTask' -and $_.GetParameters().Count -eq 1 -and $_.GetParameters()[0].ParameterType.Name -eq 'IAsyncOperation`1' })[0]

Function Await($WinRtTask, $ResultType) {
$asTask = $asTaskGeneric.MakeGenericMethod($ResultType)
$netTask = $asTask.Invoke($null, @($WinRtTask))
$netTask.Wait(-1) | Out-Null
$netTask.Result
}

$connectionProfile = [Windows.Networking.Connectivity.NetworkInformation,Windows.Networking.Connectivity,ContentType=WindowsRuntime]::GetInternetConnectionProfile()
$tetheringManager = [Windows.Networking.NetworkOperators.NetworkOperatorTetheringManager,Windows.Networking.NetworkOperators,ContentType=WindowsRuntime]::CreateFromConnectionProfile($connectionProfile)


# 检查 Windows 10 移动热点的状态
$tetheringManager.TetheringOperationalState

# 如果移动热点是开启状态,则关闭移动热点
if ($tetheringManager.TetheringOperationalState -eq 1){
# 关闭移动热点
Await ($tetheringManager.StopTetheringAsync()) ([Windows.Networking.NetworkOperators.NetworkOperatorTetheringOperationResult])
}
# 如果移动热点是关闭状态,则设置热点名称、热点的密码,然后开启移动热点
else{

# 启动前先为移动热点设置SSID、密码
$accessPoint = $tetheringManager.GetCurrentAccessPointConfiguration()
# 为移动热点设置SSID
$accessPoint.Ssid = "what"
# 为移动热点设置密码
$accessPoint.Passphrase = "A19802021823."
$tetheringManager.ConfigureAccessPointAsync($accessPoint)

# 启动/开启移动热点
Await ($tetheringManager.StartTetheringAsync()) ([Windows.Networking.NetworkOperators.NetworkOperatorTetheringOperationResult])
}

任务计划程序:powershell -ExecutionPolicy Unrestricted -f D:\HotspotOnOff.ps1

ip-网卡路由绑定

  • 获得网关ip ipconfig
  • 获得接口序号 route print
  • 配置路由 route ADD 157.0.0.0 MASK 255.0.0.0 157.55.80.1 METRIC 3 IF 2
    destination^ ^mask ^gateway metric^ ^ Interface

METRIC值设置的足够小,就能优先使用此条路由路径;
要想永久生效,请使用可选参数-p

Mysql

https://downloads.mysql.com/archives/community/

https://www.cnblogs.com/haovco/p/11258387.html
.\mysqld –initialize –console

.\mysqld install
net start mysql

mysql -h 主机名 -u 用户名 -p
mysql -u root -p

select id,process_definition_id,state,recovery,start_time,end_time,run_times,max_try_times,schedule_time from t_ds_process_instance INTO OUTFILE ‘/tmp/R_developers_cmd.csv’ FIELDS ENCLOSED BY ‘“‘ TERMINATED BY ‘|’ ESCAPED BY ‘“‘ LINES TERMINATED BY ‘\n’;

https://store.rg-adguard.net/
https://www.microsoft.com/store/productId/9WZDNCRFJ3PS
.appxbundle

SwitchHosts

https://github.com/oldj/SwitchHosts/releases

在线host
https://raw.hellogithub.com/hosts
https://github.com/ineo6/hosts/raw/master/next-hosts

https://github.com/dotnetcore/FastGithub

Github CDN加速

git config –global url.”https://ghproxy.com/https://github.com".insteadOfhttps://github.com
git config –global –unset url.https://ghproxy.com/https://github.com.insteadOf
git config -l

快捷启动工具

  • fluentSearch
  • listary
  • mouseInc
  • quicker
  • AHK

热键工具

AutoHotKey

1
2
3
4
5
6
符号  描述
#   Win(Windows 徽标键)
!   Alt
^   Ctrl
+   Shift
&   用于连接两个按键(含鼠标按键) 合并成一个自定义热键.

示例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
^j::
{
Send "My First Script"
}

热字串 - 替换/Opr
::ftw::Free the whales

:*:btw::by the way ; 不需要按下结束符.

::btw::
{
MsgBox "You typed btw."
}

::pop::
SendInput 19802021823{Enter}
return

::=-=::
SendInput {Del}{Del}{Del}{Del}proxy{Enter}
return

开机启动

我的电脑-计算机-管理-任务计划程序

可设置 系统启动时及延迟执行 来运行脚本

获取动态参数启动xshell

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/python
# -*- coding: UTF-8 -*-

import sys,os

print('参数个数为:', len(sys.argv), '个参数。')
print( '参数列表:', str(sys.argv))

# ['D:\\para.exe', '/TITLEBAR', '10.154.45.16', '/N', '10.154.45.16', '/T', '/SSH2', '10.153.97.55', '/P', '2200', '/L', '1719380262518744936', '/PASSWORD', '1639728796499']

print(sys.argv[7])
print(sys.argv[9])
print(sys.argv[11])
print(sys.argv[13])

server=sys.argv[7]
port=sys.argv[9]
username=sys.argv[11]
password=sys.argv[13]

# moba
#os.system('D:\soft\MobaXterm\MobaXterm_Personal.exe -newtab "ssh '+ username +'@'
# + server +' -p ' + port)

# xshell
os.system(r'"C:\Program Files (x86)\NetSarang\Xmanager Enterprise 5\Xshell.exe"' + ' -url SSH://' + username + ':' + password + '@' + server + ':' + port + ' -newtab ' + server)


Windows系统中添加自定义永久路由(通过route命令)

查询当前路由
route print

例子

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
例如,我们想添加一条路由,目标网段是192.168.5.0/24(掩码是255.255.255.0),下一跳是192.168.2.254,并且这条路由应用在“24”网卡接口上,那么我们就可以输入这样一条命令:

route add 192.168.5.0 mask 255.255.255.0 192.168.2.254 if 24 -p
在这个例子中:

192.168.5.0表示目标网段;

mask后面接掩码,255.255.255.0表示目标网段的掩码;

192.168.2.254表示路由的下一跳地址,也就是,想要到达192.168.5.0的数据,本机都会发给192.168.2.254去转发;

if后面接本机的网卡接口号,如果本机有多个网卡,那么就需要区分你想要用哪个网卡去访问目标网段,这里的接口号就是开头说的通过route print命令查看到的。

例如我的24号接口能够通到目标网段,那么这里就输入24;

“-p”这个参数表示该条路由永久生效。如果不加这个参数,那么需要注意,你的这条路由在本机重启后将会失效。

Soft

  • 大文件清理 WinDirStat
  • 编辑器 Notepad3
  • XShell/MobaXTerm/WindTerm
  • AutoHotKey

限制应用联网

测试未成功

1
2
3
4
5
6
7
8
9
10
11
12
13
# Create outbound rule to block internet access but allow local network
New-NetFirewallRule -DisplayName "Block Internet for MyApp" `
-Direction Outbound `
-Program "D:\soft\MobaXterm\MobaXterm_Personal.exe" `
-Action Block `
-RemoteAddress Internet

New-NetFirewallRule -DisplayName "Allow Local Network for MyApp" `
-Direction Outbound `
-Program "D:\soft\MobaXterm\MobaXterm_Personal.exe" `
-Action Allow `
-RemoteAddress LocalSubnet

visio替代

inkscape √
libreoffice draw

0%