I'm trying to create a batch where I open firefox, wait for 10 seconds so the web page is loaded and finally i take a full screenshot.
i tried "firefox www.google" and I know there is an option "screenshot --full page" but i cant make it work altogether.
My main target is clicking in a batch and getting a screenshot of several web pages. And if its possible, wait 10 seconds after opening the web page so it's loaded properly.
thanks
This is what i tried without even trying the 10 seconds delay, but it doesn't work :
firefox www.google.uk & firefox --screenshot
What about this batch script ?
#echo off
Title Take a screenshot with snippingtool by Hackoo 2018
start /min "" firefox.exe "https://stackoverflow.com/questions/50029056/batch-opening-a-webpage-and-screenshot-it-after-10-seconds"
Timeout /T 10 /nobreak>nul
Start /Wait snippingtool /clip
Start /Max mspaint
Related
I am writing a cmd batch script that runs a module called Docsify. I want to get the URL from its output and open it in a browser. The problem I have is:
It doesnt echo the output (basically just a blank display after calling the command)
I need to open it in a browser
(Worth mentioning though that when I manually open localhost:3000 in the browser, then the page actually loads fine. I am not sure why the cmd command isnt able to display the proper output)
Here is my code:
FOR /F "tokens=*" %%A IN ('docsify serve ./docsify') DO (
echo %%A
)
This is my EXPECTED output:
Serving C:\Users\me\Desktop\NodeJS\node_modules\doc-viewer\docsify now.
Listening at http://localhost:3000
But then as I've mentioned what I'm getting is just a blank display.
I also tried to just manually enter the command and force it to open localhost:3000
docsify serve ./docsify
start /d "C:\Program Files\Internet Explorer" IEXPLORE.EXE https://localhost:3000
Then the docsify output is displayed in my console, as expected. But then I need my script to open IE and go to localhost:3000. It currently doesn't do that because it is 'listening' at port 3000 (it stays on this prompt until I terminate the cmd). Is there anyway I can call a command to open IE while docsify is listening?
Any thoughts?? Thanks!
I finally found a solution. Basically I run the docsify server through docsify serve on a separate cmd window then add a timer before opening localhost:3000 on the browser.
start cmd.exe /c docsify serve ./docsify
timeout /t 3
start /d "C:\Program Files\Internet Explorer" IEXPLORE.EXE http://localhost:3000
I am trying to launch a Powerapp using MS Edge to display on a screen. I have a batch file that needs to run every 6 hours. I need to close Edge and then relaunch the powerapp link, but the problem I am having is that when the app is relaunched it is opened on a minimised window. I need to have the powerapp displaying full screen without any Edge menus or anything. This is my code at the moment. Any suggestions would be greatly appreciated. Thanks in advance.
start msedge
taskkill /F /IM msedge.exe
%windir%\system32\cmd.exe /c "start microsoft-edge:https://apps.powerapps.com/play/{app_link}&hidenavbar=true" --disable-extensions --new-window --start-fullscreen --disable-popup-blocking
I test your code, Edge is open in maximin size but Edge menus still exist. If you want to open Edge in full screen without any menus, you can use Kiosk Mode.
You can add --kiosk flag to enable kiosk mode in Edge, the sample code is like below. It can achieve what you want:
start msedge
taskkill /F /IM msedge.exe
%windir%\system32\cmd.exe /c "start msedge.exe --kiosk --disable-extensions --new-window --start-fullscreen --disable-popup-blocking https://apps.powerapps.com/play/{app_link}"
I want to open chrome using bat file, but when chrome specific process closes the cmd should close as well. I've tried it but doesn't seem to work.
"C:\Users\andreas\AppData\Local\Chrome\Application\chrome.exe"
Shouldn't the bat file be attached to the app and when the app closes the cmd window should close as well?
No it won't. Starting programs using or not using start is documented in start /? help.
When executing an application that is a 32-bit GUI application, CMD.EXE
does not wait for the application to terminate before returning to
the command prompt. This new behavior does NOT occur if executing
within a command script.
Also see http://stackoverflow.com/questions/41030190/command-to-run-a-bat-file/41049135#41049135
New behaviour refers to the Win NT4 vs Win 2000 versions of CMD.exe.
You could use start /WAIT, designed to wait for GUI application to close, but it won't solve your problem. (It would for Firefox, for example).
The thing is, when you start Chrome, it actually acts as a launcher and spawns a bunch of children processes, and then exits immediately, leaving them to show you a page.
So, if you ran start /WAIT ...\chrome.exe, it would exit at that point.
What can be done about that?
You can monitor chrome instances checking the process list like that:
launch_chrome.bat
#echo off
start /wait "chrome" "C:\Users\andreas\AppData\Local\Chrome\Application\chrome.exe"
:loop
tasklist /FI "ImageName eq chrome.exe" | find /i "chrome" > nul || goto :chrome_exited
:: wait 2 seconds before checking again
timeout /t 2 >nul
goto :loop
:chrome_exited
echo Chrome exited
Still, it won't solve your problem if you want it to run along with your already running usual chrome processes. The script will wait for you to close all of them.
In this case the options left for you are to use tools like AutoIt, AutoHotkey.
They can check the titles on all the chrome windows and if they don't see some specific string they can close the batch.
I made a batch file earlier with the code
start chrome.exe --profile-directory="Profile 1" http://drive.google.com
It opens google chrome to the page "Drive.google.com" as the profile 1 user.
However, everytime i run it it opens chrome in a tiny window. I was wondering if there was a way to open it in either fullscreen mode or a larger windowed mode. I tried the
mode con lines=1000 cols=1000
But it seems to be only for batch files. Is there a variable simlilar to the profile variable that will open it in fullscreen?
As waeswaes said you can add the /max tag
/MAX Start window maximized.
So:
start /max chrome.exe --profile-directory="Profile 1" http://drive.google.com
Right now I have a batch file I created that simple kills a chrome browser and opens up a new one to a particular homepage. I run this on a 5 minute interval with some added software that runs it if there is no activity for 5 minutes. I use this as a timeclock.
I am having some issues with the browser closing and reopening all the time. I figure I can make this script more effiecent by changing a few things.
Instead of closing and open a new browser every 5 minutes I would like to check first if the chome browser is already open and if it is then simple refresh it, otherwise open it.
Here is my current script
#echo off
taskkill /f /im chrome.exe
start "chrome" "C:\Program Files\Google\Chrome\Application\chrome.exe" --kiosk "http://www.example.com/sd/clockin/testclockin.php"
To check if Chrome is currently running, you can use the tasklist command.
tasklist | findstr chrome.exe || echo Chrome is not running
the code after || will only run if an errorlevel is set by the previous command, i.e. if chrome.exe doesn't show up in tasklist. You can use && to execute only if an errorlevel was not set.
You can also just check the errorlevel using a simple if statement -
if %errorlevel%==1 echo Chrome is running
Obviously chrome is closing because you are running the taskkill command. I assume you want to refresh the open page. You may need to look into using VBScript for this. This should help - refresh firefox from .bat file/ command.