vmrun command in task scheduler does not start a VMware virtual machine - batch-file

I am struggling to make a Task Scheduler task successfully runs a batch file which contains a vmrun command to start a VM. I am using VMware Workstation 12.5 in a Win 7 x64 (unfortunaltely I cannot test in others). I already had searched on other websites (including stackoverflow) and tried different approaches but I really do not understand what is going on with this simple command.
The command I am using to start the VM is this:
vmrun start "C:\Virtual Machines\Windows7x64\Windows7x64.vmx"
What I did so far:
run it in the command line to make sure it is working
created a batch file with the command above and run (through command line and double-clicking on it) to make sure it is working
created a task in Task Scheduler pointing to the bat file, configured with high privileges, run whether user is logged on or not
when I run the task (manually or waiting for the schedule time) I can see that the task starts running, although the VM is not started ever, and after just more than 1 minute, the task is finished with Last Run Result 0x0 (which means it succeeded through this link: https://msdn.microsoft.com/en-us/library/windows/desktop/aa383604(v=vs.85).aspx)
I tried the same approach using the command to stop the VM and it works!
vmrun stop "C:\Virtual Machines\Windows7x64\Windows7x64.vmx" soft
Anything I am missing here? Same command runs through command line and running the batch file, although not from Task Scheduler. Any hints, please? Any details I am loosing to look at?

Related

Unable to run playwright script in taskscheduler

I have wrote a script in playwright i made a .bat file to run it when i run it manually the script runs and works perfectly but i want to automate the entireprocess to run each day morning
I tried to use task scheduler but when i put the same bat file in task scheduler its not running. i tried giving it an action to start node and my script to be run as an argument but still it didnt work i looked online for ways to make this work but i couldnt find a way to make it work in windows task scheduler

ClickOnce app doesn't execute from Task Scheduler

I have a ClickOnce application that we start on Log on and recurring. After I install the application the tasks work fine, but if I reboot the machine the scripts run but they fail to start my application. I added logging to the BAT file and I know it is executed, but calling the rundll32 line produces no result and generates no errors.
If I manually run the script, from explorer, it works and task scheduler executions start working as well. Also, if I manually run the clickonce shortcut the scripts start executing from the Task Scheduler. Is there someway to verify that dfshim is loaded, or load it before executing it? What am I missing? I tried clearing the cache and that seemed to fix it on one machine, but it seems like a coincidence because it did not fix it on another machine.
VBS Script Called first(Called By Task Scheduler):
Set WshShell = WScript.CreateObject("WScript.Shell")
obj = WshShell.Run("C:\Users\brnapolitano\AppData\Roaming\FirstAmerican\TaskScheduler\AppReferenceInvoke.bat", 0)
set WshShell = Nothing
BAT Script Called Second(Called by VBS above):
rundll32.exe dfshim.dll,ShOpenVerbShortcut
C:\Users\brnapolitano\AppData\Roaming\Microsoft\Windows\Start
Menu\Programs\FastLocalService\FastLocalService.appref-ms
I would like to make this a script fix, but if that's not possible, I will try adding it to the startup and see if that resolves my issue.
I found the answer(linked below). I am still in the process of testing, but it seems to work. dfsvc needs to be run, if not active, before running the command to start the shortcut.
ClickOnce app not starting from the scheduler
It's not clear from your post what is happening after reboot. After the reboot are you trying to run the scheduled task after logon or before logon? If the latter, your vbs and bat files are most likely running under a different security context than what you think it is. That could also be the case after logon depending on the settings in your scheduled task.
See Task Scheduler is not supporting option "Run with highest Privilege" and "Run weather user is logged on or not"

Quick Test Pro (11) not running when computer is locked

I need to run QTP scripts when I'm not at work. So I'm scheduling (with windows task scheduler), batch files (which calls .vbs files) to call the QTP codes.
They run fine, if the computer is no locked (I have tried with the scheduled taks, and running the .batch directly also).
Even when the computer has been locked for a hour, the QTP scripst run fine.
But if the computer is locked for several hours (for example, if I leave work at 5 pm, and I need to run the scripts after 12 am), the QTP scripts donĀ“t run (neither an error message is popped up, nor QTP in encycled, nor nothing).
Anybody has an idea what need to be done to work this out?
Directly from UFT help file, same applies to QTP:
When running UFT tests or components on a local machine, if the computer on which the application is being tested is locked, your test run may fail.
Workaround:
Install UFT on a virtual machine (without a screen saver or lock password), and start or schedule your run session on the virtual machine. Then you can lock your local computer without locking the virtual machine.
Another workaround (not recommended):
Play any video in loop in Windows Media Player. This will prevent your machine from get locked automatically.
In this scenario you can auto schedule the script through the external free software like Auto-Sys.
There you can create jobs to unlock the machine and then run the regression.
You can simple use the below utility to keep you system unlocked
https://sumeetkushwah.com/2015/11/07/windows-lock-prevention-utility/
use the below code and save this as a .vbs file(SomeName.vbs)
Set WshShell = WScript.CreateObject("WScript.Shell")
Do
WshShell.SendKeys "{CAPSLOCK}"
WScript.sleep (1000) '1000 means one second. choose the time of your liking
WshShell.SendKeys "{NUMLOCK}"
Loop
Double click the saved vbs file. Your computer will not get locked unless you manually kill the WScript.exe task in your task manager. Use the keys of your choice from here http://www.pctools.com/guides/scripting/detail/149/?act=reference

Why running .bat file thru Task Scheduler is not starting the .Jar file fully?

Here is what is going on. I have created a .Bat file containing start javaw -jar BTG_Producer.jar When I start this manually by double clicking it will show my java program in my system tray and shows the process "javaw.exe *32" in Windows Task Manager. When I run this thru Task Scheduler it starts the process "javaw.exe" with out the *32 and does not show the program in the system tray. Do you guys know what I am doing wrong?
When you launch a process via Task Scheduler, it may have a different environment than when you launch the process from your desktop. To test this, you can create a task that runs cmd with the /k parameter from the Task Scheduler. When you run it, cmd will open, then you can run set >%userprofile%\Desktop\environment1.txt. Then, open a cmd as you normally do, and run set >%userprofile%\Desktop\environment2.txt. Open the two files side by side, and compare.
In this case, I suspect your PATH variables are different, which is why 32-bit java is run in one case, and 64-bit in another.
To fix this, you could explicitly specify the 64-bit javaw.exe in your batch file.
C:\path\to\javaw.exe instead of just javaw.

Jenkins task to switch on monitor if it's switched off

I use Jenkins to run our builds. What I want to do is to wakeup the monitor before build starts. This is what I have done so far.
Use nircmdc.exe (http://www.nirsoft.net/utils/nircmd.html) and prepare a batch file to turn on monitor. I have tested the script through command prompt and it works fine.
Then I add a build step in Jenkins to execute windows batch file before running the ANT script. Then I remote start the build (via URL). Console shows that the batch file is being executed. But the monitors doesn't wake up.
Then I included a target in ANT to execute the same batch file and tested running the ANT via CMD. This wakes up the monitor and continue with the build steps.
But, if I run this ant script from Jenkins, everything works fine except waking up the monitor.
Is this something to do with privileges ?
Has someone done something similar?
Don't think I've ever heard of a requirement to wake up the monitor, so probably no one has done anything like this.
However, your problem is probably due to Jenkins process running in a separate session from your machine's console. Have a look at my answer here: Open Excel on Jenkins CI, it explains how to get around the session issue.

Resources