View Single Post
Old 03-14-2012, 11:36 PM   #76
Hypernova doesn't litterHypernova doesn't litter
Posts: 78
Karma: 190
Join Date: Feb 2009
Device: Current: PW1. Past: Kindle DXG;Pocketbook 360
Powershell script for starting the vnc viewer

I put together something so it's more convenient to start/quit the whole process. It's a powershell script to run UltraVNC, wake up the Kindle, prevent sleep using kaffeine(optional), and start vncviewer. When you hit enter, it will close the viewer, exit kaffeine and UltraVNC. I use the script from and SharpSSH.

You have to put your ssh/vnc's username/password at the beginning of the script and place the content of the 7z file in the same directory as UltraVNC folder (or just change the path yourself).

Here's the Powershell script for reference

#Script path
$spath=Split-Path -parent $MyInvocation.MyCommand.Definition

#Start winvnc if not already running
if (-not($ultravnc=Get-Process winvnc -ea 0))
    $ultravnc=Get-Process winvnc

#dot source ssh_function
. ($spath+"\ssh_function.ps1")

#Create ssh session
New-SshSession -UserName $sshuser -Password $sshpassword -HostName $hostname
#Wake up the kindle
Send-Ssh("lipc-set-prop com.lab126.powerd wakeUp 1")
#Run vncviewer
Send-Ssh("/mnt/us/kindlevncviewer/ -password $vncpassword &")
#Prevent sleep using kaffeine

#Wait for Enter key
Read-Host -Prompt 'Press Enter to close VNC' | Out-Null
#Kill vncviewer
Send-Ssh("killall kindlevncviewer")
#Exit kaffeine
Send-Ssh("/mnt/us/system/kaffeine 3")
#Kill winvnc

#Close ssh session
Now I can simply run the script. Thanks hawhill and everyone again for your work. This is awesome.
Attached Files
File Type: zip (155.0 KB, 103 views)

Last edited by Hypernova; 03-15-2012 at 06:05 PM. Reason: Add attachment
Hypernova is online now   Reply With Quote