
![]() |
stefan
EDIT: wrong forum. New here...Shoudl have been in C# code repository - sorry, Please move it fellows...
This is a very sloppy contribution, I guess I could have given you more exact info on the sdks - but I am so busy coding these days...not sure if this is "too" basic for this rather impressive forum either but here I go I have VMWare server setup - one one of those virtual boxes I run Tor/Privoxy. On the host I have a few apps running at occasions. However, automation is king, so I want those apps to check if that VMWare virtual machine isn't running I need the app to start it up automagically.1. I use C# 2. There is a SDKAPI for VMWare. Active X controls. To be honest I am not sure (was a month ago or so) if I did download something fromhttp://www.vmware.com/download/ sdk/or of files are always there after installing VMWare server: C ![]() 3. I have created a VM called TorPrivoxy which is what we want to check if running - and if not, then fire it up 4. Now for the code using System; using System.Collections.Generic; using System.Text; using VMCOMLib; namespace ControlPanelJobs { public class EnsureProxy { public static void Ensure() { VmConnectParams vmConn = new VmConnectParams(); vmConn.Hostname = "localhost"; vmConn.Username = "administrator"; vmConn.Password = "foobaradminpassword"; VmServerCtl vmSrvCtl; vmSrvCtl = new VmServerCtl(); vmSrvCtl.Connect(vmConn); foreach (string s in vmSrvCtl.RegisteredVmNames) { if (s.IndexOf("TorPrivoxy" ![]() { VmCtl vm = new VmCtl(); vm.Connect(vmConn, s); if (vm.ExecutionState != VmExecutionState.vmExecutionState_On) { vm.Start(VmPowerOpMode.vmPowerOpMode_TrySoft); System.Threading.Thread.Sleep(60 * 1000); } } } } } } I am not sure if it's possible to check when it's up - I guess one single way is just check if the proxy is indeed available , but this one is easy - waiting 60 seconds IS enough and I have no hurry in these cases. You need to change the admin name and password of course. For non C#ers - there ARE PerlAPI:s as well.The main reason for me needing this is I have found myself - when disturbed by a customer on phone etc - I sometimes (without knowing it) click around my open windows - and it has happened I closed the whole virtual machine down... |

Thread Categories

![]() |
![]() |
Best of The Cache Home |
![]() |
![]() |
Search The Cache |
- Ajax
- Apache & mod_rewrite
- BlackHat SEO & Web Stuff
- C/++/#, Pascal etc.
- Database Stuff
- General & Non-Technical Discussion
- General programming, learning to code
- Javascript Discussions & Code
- Linux Related
- Mac, iPhone & OS-X Stuff
- Miscellaneous
- MS Windows Related
- PERL & Python Related
- PHP: Questions & Discussion
- PHP: Techniques, Classes & Examples
- Regular Expressions
- Uncategorized Threads