I'm trying to configure a virtual machine to start up from the machine being powered on. I have that working. Now I want to be able to shut down the entire machine once someone clicks Shutdown on the start menu of the virtual machine.
I'm using VMware with Windows 7 images, if that helps.
Thank you!
invoke the start of the virtual machine with some kind of wait option and invoke shutdown afterwards.
Something like this
start /wait vmware-cmd cfg.vmx start
shutdown -s
I don't have any vmware installed, I can't test it right now so I can't make sure the vmware-cmd doesn't return right away. If that is the case, then you must look for some loop mechanism in your bat file, something like
vmware-cmd cfg.vmx start
:again
vmware-cmd cfg.vmx getstate >state.txt
if (state.txt contains some string indicating still running) goto again
shutdown -s
Related
I'm trying to run an exe on multiple pcs on sync.
Im using psexec, this is what I have till now:
I have a batch file with this:
start psexec \\pc01 -i -s -d c:\videos360\video360.exe
start psexec \\pc02 -i -s -d c:\videos360\video360.exe
With this I can start the exe in the 2 pcs, but never totally on sync.
Anyone has some idea of how can I make them run more on sync?
Thanks in advance.
Sorry for my bad English...
First sync the clocks on both machines. You can run a script on one of them to sync to the other or have them both sync to a central time source. Then add a task to Task Scheduler on each machine to start the application at the same time. That's about as close as you're going to get without resorting to some sort of IPC mechanism between the processes (requires source code access to video360.exe).
See
schtasks.exe
Windows time service tools
You won't need psexec because schtask can be used to manage tasks on the remote machines. It would be up to your script to change the next time to fire the task, or you could setup a repetitive task that fires every minute or two and just enable/disable the task. I believe there's a one-shot option as well.
I have gotten tired of searching how to stop Windows Updates from running permanently in Windows 10 since every after a restart it runs again. It came to my mind that maybe I could make a .bat file that could stop the windows update in the services so that I could just click it every time I turn on my laptop.
I have known of the sc start/stop serviceName. My question is, what is the name of the Windows Update service? Because when I type in windows update in in the serviceName, it would show that the service is not installed.
simple batch which you can even put into your Run at start up. This one works on Windows 8 and older should perhaps work on Windows 10 as well.
#echo off
net stop "Windows Update"
You can also stop it together with the background downloading processes.
This one works on windows 10
#echo off
net stop wuauserv
net stop bits
net stop dosvc
The name of your service is wuauserv.
If you want to get a list of display names with their associated service names you can do so relatively quickly by utilising WMIC at your Command prompt.
WMIC /Output:Services.txt Service Get DisplayName,Name&&Services.txt
The Services.txt file will be located in the Command prompt's current directory.
The powershell commands to :-
Stop Windows update is:
Stop-Service wuauserv (Run as admin)
Start Windows update is:
Start-Service wuauserv
Unplug the LAN wire or disconnect your system from the internet as soon as possible. Write "Services.msc" in a run (Windows key + R), then scroll down and search Windows update option there. Double click on that, select the startup type "disabled" then click ok, it will stop the windows update and also fix blue screen problems during upgrade on Windows 10.
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
Probably a really obvious question, I'm trying to run some sequential batch code to define my own eclipse external run configurations.
One of the calls in the .bat is to run a jetty server, and after this I want to launch a program. At the moment the execution of the .bat means that the call to run jetty hangs on that call, and the call to open the program is only executed once the jetty server has been killed.
Is there any way I can run the call to start jetty, and then immediately run another call to open any program that wont have to wait for the server to be killed.
You can use start to run a program in the background explicitly:
start "" "C:\Program Files\etc.\blah\x.exe"
Execution of the batch file immediately continues after that line. In case of jetty you're probably starting Java anyway. cmd doesn't wait for GUI processes so you can also use
javaw -jar ...\jetty.jar
instead of calling java.
Since the question has changed a bit after the comment:
If there is a reliable way of knowing when jetty has started, e.g. a file that will exist somewhere
:l
timeout /t 1 >nul
if not exists %temp%\somefile goto l
you could use that. Otherwise you can just wait for a while
rem wait two minutes
timeout /t 120 > nul
and hope that everything has started by then.
I have a web application, that sometimes hangs. I want to investigate the reason, and I need to get a memory dump of the process, when it hangs.
So my idea is to monitor the website, when I am detecting the hang, I want to start a .bat script which captures the memory dump, then runs IISRESET in order to restart so that the site will start responding again.
My problem is, that adplus starts another process (cdb.exe) and returns immediately. I need to wait for cdb.exe to finish, before I can run IISRESET. Is there any way to do that in a batch script ? Or, can I specify on the adplus command line, that it should not return until the memory dump has been collected ?
Regarding the second part of your question, the answer is yes: you can both (1)specify the wait on the commmand line (as long as you can access to and modify it); and (2)wait for a process to finish in a batch file.
In their simplest form, do
(1) use START /WAIT cdb parms instead of just cdb parms
(2) try FOR /F "tokens=1,2" %a in ('TASKLIST ^| FIND /I "cdb.exe"') DO #ECHO %a %b and substitute ECHO for the command you want.
To create the memory dump of your web application, the Microsoft Debug Diagnostic Tools are your best option.
You can create an "IIS Hang" rule, monitoring a specific URL, and creating a memory dump whenever no response is received within a specified number of seconds.
The Debug Diagnostics Tools will not help you with regard to restarting IIS (or your app pool), but in general the built-in Application Pool restart options should be sufficient for that. If you make sure "Enable Pinging" is set for your AppPool (on its Health tab), and you also set the other Health/Recycling parameters appropriately, your app should continue responding no matter what happens.
If not, monitoring the output folder with crash dumps from your "IIS Hang" DebugDiag rule, and restarting IIS whenever new files appear should definitely do the trick...