I’ve been setting up a Cuckoo cluster and the most tedious part of that involves configuring the guest VMs. To make a long story short, I needed to manually set the IP address of all my guest VMs. At first I started doing this the visual way by clicking through all of the windows settings menus. This quickly got tedious so I developed an applescript which opens the command prompt in administrative mode, bypassing the stupid user warning, enters the command to change the ip address of the box, and then closes the command prompt. If you have a task which involves monkeying with a windows system using Screen Sharing on a mac, I hope you find this little script useful.
tell application "Screen Sharing" activate delay 1 tell application "System Events" -- Open an administrative command prompt key code 53 using control down delay 2 keystroke "cmd" delay 1 key code 125 key code 126 key code 76 using {shift down, control down} delay 2 key code 123 key code 76 delay 2 keystroke "netsh interface ip set" delay 1.2 keystroke " address name" key code 24 keystroke "\"Local" delay 1.2 keystroke " Area Connection\"" delay 1.2 keystroke " static" delay 1.2 keystroke space -- Numbers have to be entered by key code. Otherwise they are interpreted as control characters key code 18 key code 25 key code 19 key code 47 key code 18 key code 22 key code 28 key code 47 key code 23 key code 22 key code 47 key code 18 key code 29 -- This is the part that needs to change -- key code 29 -- 0 -- key code 18 -- 1 -- key code 19 -- 2 -- key code 20 -- 3 -- key code 21 -- 4 -- key code 23 -- 5 -- key code 22 -- 6 -- key code 26 -- 7 key code 28 -- 8 -- key code 25 -- 9 keystroke space delay 1.2 key code 19 key code 23 key code 23 key code 47 key code 19 key code 23 key code 23 key code 47 key code 19 key code 23 key code 23 key code 47 key code 29 keystroke space delay 1.2 key code 18 key code 25 key code 19 key code 47 key code 18 key code 22 key code 28 key code 47 key code 23 key code 22 key code 47 key code 18 delay 1.2 -- Send the command keystroke return delay 2 -- Exit the command prompt keystroke "exit" keystroke return end tell end tell