vncdotool - A command line VNC client

作者:Daly 出处:http://www.cnblogs.com/daly 欢迎转载,也请保留这段声明。谢谢!

之前的一个项目需要需求希望可以通过命令行去远程执行一些Windows 系统操作。

所以决定采用: Python + vnctool

环境准备:

1. 2 台Windows机器。 其中一台作为lead机器, 一台作target机器。

2. Python2.7.5, VNC-5.0.5安装包和其他一些依赖包。 具体可以参考以下步骤。

On the lead machine:

1. Install Python2.7

1.1. Start with a Windows

1.2. Install python via python-2.7.5.msi

1.3. Set the Environment Variables (2 methods):

a. Open up PowerShell, and paste in the following:

[Environment]::SetEnvironmentVariable("Path",

"$env:Path;C:\Python27\;C:\Python27\Scripts\", "User")

b. Right click Computer and select "Properties" > click "Advanced system settings" > click "Environment Variables..." > select "Path" in "System variables" field and click "Edit" > add "C:\Python27\;C:\Python27\Scripts\;" at the "Variable value"

2. Install Twisted

2.1. Install Twisted via Twisted-13.1.0.win32-py2.7.exe

3. Install PIL

3.1. Install PIL via PIL-1.1.7.win32-py2.7.exe

4. Copy 2 scripts to C:\Python27\Scripts

4.1. Copy file ez_setup.py and get-pip.py to C:\Python27\Scripts

5. Install setuptools

5.1. Download setuptools-1.1.6

5.2. Launch CMD and input the follow commands to install setuptools:

> cd c:\setuptools-1.1.6

> python setup.py install

6. Install pip

6.1. Download pip-1.4.1

6.2. Launch CMD and input the follow commands to install pip:

> cd c:\pip-1.4.1

> python setup.py install

7. Install distribute

7.1. Download distribute-0.7.3

7.2. Launch CMD and input the follow commands to install distribute:

> cd c:\distribute-0.7.3

> python setup.py install

8. Install zope.interface

8.1. Download zope.interface-4.05

8.2. Launch CMD and input the follow commands to install zope.interface:

> cd c:\zope.interface-4.05

> python setup.py install

9. Install vncdotool

9.1. Download vncdotool -0.8.0

9.2. Launch CMD and input the follow commands to install vncdotool:

> cd c:\vncdotool -0.8.0

> python setup.py install

 

VNC Server installation(Install it on the lead machine and the target machine)

1. Install VNC Server

1.1. Download VNC-5.0.5-Windows.exe

1.2. Install VNC via VNC-5.0.5-Windows.exe

 

VNC Configuration (Configure it on the lead machine and the target machine)

1. After install VNC Server successfully, right click VNC icon in the bottom right corner of the toolbar > select "Options..."

 

2. Then select the "Advanced..." button:

 

3. Choose Authentication as "VNC password" and click "Configure.." > input the password to configure > choose Encryption as "Prefer off"

 

4. Select tab "Expert" > set the "ProtocolVersion" for the VNCServer to 4.0.

 

5. Click "Apply" and click "OK" to finish the configuration

 

VNCDO usage

1. Test the vncdo take effect:

On the lead machine, at the CMD prompt input:

> vncdo.exe -s xxx.xxx.xxx.xxx[the target machine's ip]  -p password[the password you set at VNC Configuration #3]  capture screenshot.png

you will get the target machine's currently screenshot

2. vncdo usage

a. Input "vncdo --help" in CMD to get the vncdo all usage

b. Some useful usage:

>vncdo -s xxx.xxx.xxx.xxx -p password type "hello"

>vncdo -s xxx.xxx.xxx.xxx -p password key ctrl-alt-del expect a.png 0

>vncdo -s xxx.xxx.xxx.xxx -p password type "administrator" key tab type "password" key enter expect d.png 0

 

3. Get more info from the website: http://pythonhosted.org/vncdotool/

https://pypi.python.org/pypi/vncdotool

 

转载于:https://www.cnblogs.com/daly/p/4679341.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值