Parallels VM: Is there a way to run a script on the host when launching a VM? - parallels

My Parallels VM is configured to use some network services on the host mac via the virtual network, but as the virtual network is not up when the mac host's services are started at boot they aren't listening on the virtual interface and the VM can't connect to them. After starting the VM I have to remember to manually restart those services on the mac host so that they are listening on the virtual network. It's annoying when I forget to do so...
I'd like to automate this process if possible. Is there any way to configure Parallels to run a shell script on the host after a VM is started and the virtual network is up? (Suggestions for how to run a startup script on the guest VM are not germane.)

You can prepare script using Automator. Script must be a type "Application". For your purposes, the "Run Sell Script" action is probably the best suited, but you may need something else. After the script is prepared and debugged, you need to move the .app bundle of this script needs to /Applications
Then check in the VM configuration that Options / Aplications / Share Mac applications with Windows are enabled.
Start the VM (or restart it if it's running).
Please find the element with the scipt name at the Parallels Shared Applications folder in Windows Start menu.
Then please right click on it, choose More / Open file location.
Try to launch script by double-clicking on it.
If the "allow open applications" dilog box is appeared, please select "Always Allow".
Press Cmd+R, type "shell:startup", then press OK and copy the element with the script name from the previously opened window to the new appeared window.
That's it.
Now, every VM startup, a script will be launched on the host.

Related

Autohotkey on a remote desktop does not work when I disconnect my local desktop

Im am using Autohotkey to rerun Pytest every ten minutes on a Virtual machine offered my Microsoft Azure.
My .ahk script is simple.
loop
{
Send !{F10}
Sleep, 600000
}
The script works perfectly while Im connected to the remote desktop. But if I exit the full screen or disconnect from it., it does not work. The Autohotkey keeps on running but for some reason just does not register Send !{F10}.It only starts registering it when I connect back on it. Please help.
Autohotkey not functioning properly on minimized virtual machines is an issue that's been around for a while, with
(regarding Virtual Machines):
RemoteAdmin server process launches a program on request of remote
user (you). So R.A. is a parent process for AHK. Once you minimize
your RA session client it signals the RA-server that. RA-server thinks
now that since the client is minimized it does not need anything and
to consume CPU power it halts any activity of itself and its child
processes.
-wOxxOm
And in the documentation of other AHK functions, such as WinActivate
Known issue: If the script is running on a computer or server being
accessed via remote desktop, WinActivate may hang if the remote
desktop client is minimized. One workaround is to use commands which
don't require window activation, such as ControlSend and ControlClick.
Another possible workaround is to apply the following registry setting
on the local/client computer:
; Change HKCU to HKLM to affect all users on this system.
RegWrite REG_DWORD, HKCU, Software\Microsoft\Terminal Server Client
, RemoteDesktop_SuppressWhenMinimized, 2
^^The above registry change may potentially solve your issue as well^^
The forum thread provides a couple of different workarounds for this issue, but if you are just trying to put the VM out of the way while you do other stuff on your computer, the least gimmicky solution that I can think of would be to move the Virtual Machine window on the host computer to a Virtual Desktop by either using the Win+Tab shortcut or by using this guide. By moving the window to a virtual desktop, the Virtual Machine will moved out of the way in a manner where it would not be minimized, allowing it to continue running the AHK script. Additionally, you can quickly navigate between Virtual Desktops with the Ctrl+Win+← and Ctrl+Win+→ shortcuts.

Minikube on Windows does nothing on start

I have followed all the instructions on Minikube carefully (I thought). I installed it on Windows 10 (ver 1.7.2), started a Powershell console under Administrator, set the 3 PROXY variables (I am behind a proxy), enabled the Microsoft-Hyper-V, and ran the cmd: minikube start --vm-driver=hyperv
It downloads the VM boot images, then I get the following line output:
* Creating hyperv VM (CPUs=2,....etc) ....
AND THAT'S IT!
Nothing else!! If I start the Hyper-V Manager I don't see any VMs there. The .minikube directory is populated with several dirs and files. But for the rest I am completely blind!
I have left it to run for half an hour or more. Still nothing.
I have tried terminating the process, stopping, deleting (in this case I get the output 'Deleting Kubenetes cluster' but whether this means anything I don't know) and flushing the .minikube directory ... then running it all again off a clean base. NADA! NOTHING! same thing!
Could someone please tell me what I am doing wrong? I thought this was supposed to work out of the box! Why don't I see my VM in Microsoft-Hyper-V manager for a start? I don't even get as far as seeing starting Kubenets cluster, yet I get no errors!
Try to follow this guide. It has a step by step instructions bout how to setup Docker and Minikube on windows 10 with Chocolatey.
Also here you will find an analogical issue with possible solutions.
Before you start again, remember to delete the .minikube folder after executing minikube delete to avoid any leftover configuration to persist.
Please let me know if that helped.
For the record, I flushed everything .. and tried several things from the above page, the K8 site and elsewhere. In a nutshell Docker for Desktop works and Minikube doesn't (not 100% anyway)! I was just curious back in February as to whether I could set up a local Kubenetes environment quickly and easily and I am afraid for me the answer is No: Minikube is not quick and easy. Also, you can enable Kubenetes on Docker Desktop now of course and it works out of the box as software should, so no more need for Minikube.
The following are the instructions for setting up and installing Minikube and its dependencies for use on Windows Pro or Enterprise with Docker Desktop and HyperV.
Install Kubectl
Create a new directory that you will move your kubectl binaries into. A good place would be C:\bin
Download the latest kubectl executable from the link on the Kubernetes doc page:
https://kubernetes.io/docs/tasks/tools/install-kubectl/#install-kubectl-on-windows
Move this downloaded .exe file into the bin directory you created.
Use Windows search to type “env” then select “Edit the system environment variables”
In the System Properties dialog box, click “Environment Variables”.
In System Variables click on the “Path” Variable and then click “Edit”
Click “New” and then type C:\bin
Drag the newly created path so that it is higher in order than Docker's binaries. This is very important and will ensure that you will not have an out of date kubectl client.
Click "OK"
Restart your terminal and test by typing kubectl into it. You should get the basic commands and help menu printed back to your screen. If this doesn't work try restarting your machine.
Run kubectl version to verify that you are using the newest version and not the out of date v1.10 version.
Install Minikube
Download the Windows installer here:
https://github.com/kubernetes/minikube/releases/latest/download/minikube-installer.exe
Double click the .exe file that was downloaded and run the installer. All default selections are appropriate.
Open up your terminal and test the installation by typing minikube. You should get the basic commands and help menu printed back to your screen. If this doesn't work try restarting your machine.
Configure HyperV
In Windows Search type "HyperV" and select "HyperV Manager"
In the right sidebar click "Virtual Switch Manager"
Leave selected "New Virtual network Switch" and "External" and click "Create Virtual Switch"
Name the switch "Minikube Switch" (or whatever you would like to name it)
Click Apply and acknowledge the "Pending changes" dialog box by clicking "yes"
Once the switch has been created, click "Ok"
Starting Up Minikube
Since by default Minikube expects VirtualBox to be used, you need to tell it to use the hyperv driver instead, as well as the Virtual Switch created earlier.
Start up a terminal as an Administrator. Then, in your terminal run:
minikube start --vm-driver hyperv --hyperv-virtual-switch "Minikube Switch"
NOTE: all minikube commands must be run in the context of an elevated Administrator.

Connect to iDrac Virtual Console programmatically

I frequently connect to the virtual console provided by iDrac on many Dell servers which I manage. I'm looking for a way to connect to the virtual console programmatically, or whatever method that's faster than logging into the web interface manually and going through all the prompts.
Dell's racadm tool does not support this, apparently. iDrac is not set up with domain auth, just using a local account configured on iDrac. I would be connecting from a Windows machine, any browser.
Is there any way to automate this? Even partially?
I use a shell script for this, you can make a .bat file on Windows. See some simple instructions to start iDrac console from command line here

Jenkins windows slave service does not interact with desktop

I have followed this guide to install a jenkins slave on windows 8 as a service:
https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+as+a+Windows+service#InstallingJenkinsasaWindowsservice-InstallSlaveasaWindowsservice%28require.NET2.0framework%29
I need to run a job that interact with the desktop (run an application that opens a browser etc.). So after I have installed the slave as a service (running jnlp downloaded from the master) I have changed the service "Log on" to "Allow to interact with display".
For some reason its only possible to enable this for the "Local System account" even though its recommended to run the service as a specified user, eg. jenkins.
But nothing happens when I execute the job, the browser is not opened. If I instead stop the service and just launch the slave through the jnlp file the job runs fine - the browser is opened.
Anybody had any luck interacting with the desktop when running a jenkins windows slave as a service?
Services run since Vista in Session 0 and the first user is now in Session 1. So you can't interact any longer. This is called Session 0 Isolation.
Microsoft explains this here and here. You have to use 2nd Program which uses IPC to communicate to the Service.
I had lots of issues running Jenkins in Windows using the service.
Instead I now disable the service and run it from CMD.
So open CMD.
cd C:\Program Files (x86)\Jenkins
java -Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar
jenkins.war --httpPort=9091
To resolve it, first create Windows auto-logon as I explain here:
https://serverfault.com/questions/269832/windows-server-2008-automatic-user-logon-on-power-on/606130#606130
Then create a startup batch for Jenkins agent (place it in Jenkins directory). This will launch agent console on desktop, and should allow Jenkins to interact with Windows GUI:
java -jar slave.jar -jnlpUrl http://{Your Jenkins Server}:8080/computer/{Your Jenkins Node}/slave-agent.jnlp
(slave.jar can be download from http://{Your Jenkins Server}:8080/jnlpJars/slave.jar)
EDIT :
If you're getting black screenshots (when using Selenium or Sikuli, for example), create a batch file that disconnects Remote Desktop, instead of closing the RDP session with the regular X button:
%windir%\system32\tscon.exe %SESSIONNAME% /dest:console
Consider running the Java slave server directly at startup and then using something to monitor and restart should the server go down (e.g., Kiwi Restarter).
Please check the services (# TestNode) make sure the "Interactive Services Detection" service is STARTED, by default the startup type is set to Manual, you may like to set it to automatic as well.
After service started, when you run your test in the Test Node, you will see something like the below:
Click on it and choose view the message
You will see the activities happen there. Hope this helps :D
Note: If login with other account and cannot view the Interative Services Detection prompt, restart the service again.
My Jenkins Service runs as user "jenkins" and all I did was to create Desktop folders in: C:\Windows\system32\config\systemprofile\desktop and if 64 bit Windows also in C:\Windows\SysWOW64\config\systemprofile\desktop - then it runs perfectly.
Make sure that Desktop folders are created as such:
%WINDOWS%/System32/config/systemprofile/Desktop
%WINDOWS%/SystemWOW64/config/systemprofile/Desktop
Presence of those can sometimes be mandatory while running some Java software as a Service.

Scheduled execution of Testcomplete fails

With TestComplete 8 we have a script that is scheduled to start 06:00 every morning by this line:
"C:\Program Files\Automated QA\TestComplete 8\Bin\TestComplete.exe" "C:\Attracs\TestComplete\Attracs\AttracsTEST\AttracsTESTProject.mds" /r /e /SilentMode
The problem is that this often fails. The log remark says:
An error occurred while calling the "Keys" method or property of the "TcxCustomInnerTextEdit" object.
The object or one of its parent objects does not exist.
If I connect to the computer with Remote Desktop and manually run the script it works fine.
There is no screensaver active and the power scheme is set to never sleep.
I have noticed that Testcomplete needs a handle to GUI (the screen is visible) or the script got this kind of errors. Could it be that when it starts it have no handle to the GUI components because they aren't visible ?
From the helps Running Tests via Remote desktop:
However, if you minimize the Remote Desktop window (the window that display the remote computer’s desktop), the operating system switches the remote session to the GUI-less mode and does not display windows and controls. As a result, TestComplete (or TestExecute) is unable to interact with the tested application’s GUI, as the GUI does not actually exist in this case and your automated GUI test fails.
To avoid this issue, you can keep the Remote Desktop window visible during the test run, but this may be inconvenient as it occupies some part or even your entire screen and leaves less space for you to run your local applications.
Any solution for this?
There is a way to enable the console connection in Windows to be active at all times, which allows TestComplete to work without actually connecting with RDP.
From: Running Tests in Minimized Remote Desktop Windows
Log in to the computer from which you
connect to remote computers.
Close all open Remote Desktop
sessions.
Launch the Registry editor
(Regedit.exe).
If you have a 32-bit operating system:
Locate the
HKEY_CURRENT_USER\Software\Microsoft\Terminal
Server Client\ Registry key if you
want to change the connection settings
for the current user only.
-- or --
Locate the
HKEY_LOCAL_MACHINE\Software\Microsoft\Terminal
Server Client\ Registry key if you
want to change the connection settings
for all the users.
Create a new DWORD value in this key
and name it
RemoteDesktop_SuppressWhenMinimized.
Specify 2 as the value data.
If you have a 64-bit operating system:
Locate the
HKEY_CURRENT_USER\Software\Wow6432Node\Microsoft\Terminal
Server Client\ Registry key if you
want to change the connection settings
for the current user only.
-- or --
Locate the
HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Terminal
Server Client\ Registry key if you
want to change the connection settings
for all the users.
Add the
RemoteDesktop_SuppressWhenMinimized
value to the key.
I found this page
http://www.automatedqa.com/support/viewarticle/12567/viewarticle.aspx?aid=12567
It seems that a solution could be that running TestComplete in a Virtual machine.
/Roland
To run any UI test, the UI needs to be available. Hence, the machine should be unlocked so that TestComplete can perform user actions like mouse click, keys, etc to work.
However, if you have non UI test like running Web Services then it will work.