Friday, August 4, 2017

Launch VM machine on startup Windows Server

I wanted to launch a VM on startup. The way that VMware suggests you do this is by creating a shared VM which was not an option for me as those have some limitations. I tried running VMware Workstation as a service but that didn't quite work either as it would run the VM but when I logged on as the Administrator in Windows Server and try to logon to the VM it would be locked with a message popping up asking if I want to take over.

The solution to this problem was found on a StackExchange Server Fault thread. I am pasting the solution posted by the user Marcus here:

Figured out how to do it myself. It's somewhat of a workaround but that's what I expected to get.
Stop! Don't cringe just yet. Read on...
  • Run it, set it so that Administrator should log on automatically.
  • Create a task in Task Scheduler. Set it to run only when user (Administrator) is logged on. Trigger is "at log on" and specify that it's only when Administrator logs on.
  • Create a second task. Run only when user is logged on, trigger at admin log on. Action should be "start a program" and program is "C:\Windows\System32\rundll32.exe" with the argument field set to "user32.dll, LockWorkStation".
What happens now if you restart the computer is that Administrator automatically logs on, the program you want to start is started and the work station becomes locked. If I log in via Remote Desktop Connection I can see the program window and use the GUI. I can lock/unlock the computer with no problem and disconnect/reconnect as I please. There's no issue if I go to the server and log in at the actual workstation either. Since Administrator is already signed in the task will not run again (it doesn't create some infinite log-in-lock-loop that you can't break out of).
Simple as that. Granted there is a one second time period before the computer becomes locked after the auto login and I guess a pro hacker with physical access to the computer could do something sneaky during this time window but in my case I can overlook that security risk. As long as I don't let any pro hackers into my home and show them the computer the system should be relatively safe. Above all there isn't that much of value on the computer that needs super-vault protection so I'm quite happy with this solution.

Tuesday, August 1, 2017

This virtual machine appears to be in use. - Take Ownership fix

If after a power failure, or reboot of you machine, you encounter the "This virtual machine appears to be in use." message when attempting to connect to your VM's, follow the steps below to remove the message:
  1. Shutdown VMware.
  2. Locate the folder where your VM is stored.
  3. Locate one or more .lck or .lock files and delete them. If you are uncomfortable deleting these files, back them up in a separate folder.
  4. Restart VMware and run your VM.
The message should not appear.

Delete all files of a specific extension from the directory that is executed, and all it's subfolders - Ubuntu - OSX

The following commands will affect all files of the specified extension from the directory that is executed, and all it's subfolders. It should work on all UNIX based operating systems:

Execute this command first in order to display all the files that are to be deleted (replace EXT with the desired extension):
find . -name "*.EXT" -type f
Executing this command will delete the list of files that the previous command returned (replace EXT with the desired extension):
find . -name "*.EXT" -type f -delete