Open PDF with Edge in Fullscreen through Batch - batch-file

at the moment im trying to open a pdf file %UserInputID%.pdf in fullscreen but i dont quite get it to work.
At the moment im just doing start "" /max "path\%UserInputID%.pdf".
I did find out about outdated workarounds with powershell that use SendKeys but as that is not completly supported anymore (?) i thought about using the startparameter of edge/chromium. But how? How to use --start-fullscreen as a parameter? Just appending it like -parameter \%UserInputID%.pdf" ---start-fullscreen does not work, neither does /parameter \%UserInputID%.pdf" /--start-fullscreen. Happy for every answer or hint.
*Edge is the standard pdf programm
*Edit / Addendum: After KJ's Answer I also figured
start "name" "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" --start-fullscreen file:///"path\%UserInputID%.pdf"
as a (partial) valid answer. Partial because if only a single (partial) instance of edge is still open (normal x doesnt do the job) it wont work, as it seem like it cant "start" in fullscreen if it is already open in non fullscreen mode.

There are in your case two ways to use MSEdge
The first as you know is if it is the default pdf application then it will use current edge profile to open the pdf so as you describe we can simply use
start "" /max "mydemo.pdf"
And Edge will use its default settings to display MyDemo.PDF in a window but will ignore the /MAX request.
It is the same if we call it directly
start "" /max msedge "file:///C:\mypath\mydemo.pdf"
However we can use it in Kiosk mode
start "" "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" --kiosk --no-first-run --edge-kiosk-type=fullscreen file:///C:\mypath\mydemo.pdf
if you wish you can also add a minute timer for auto release to normal mode but it is minutes not seconds
--kiosk-idle-timeout-minutes=1
as comment added to question you can also run the second session as
start "" "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" --start-fullscreen --no-first-run --edge-kiosk-type=fullscreen file:///C:\mypath\mydemo.pdf

Related

how to switch browser tabs using batch

I have created two independent batch files. Both open web browsers. One opens Firefox and the other Opens Edge. Both batches are opening multiple tabs in their respective applications. How do I write a batch to pass through the Control + Tab keys in batch at the end of my file to go back to the first tab?
Can this be done with Edge and Firefox? Can they be written the same way?
I don't need the tabs to refresh upon the switch.
I've tried this for Edge,
#echo off
start microsoft-edge:"https://stackoverflow.com"
start microsoft-edge:"https://google.com"
timeout 2
$wshell=New-Object -ComObject wscript.shell;
$wshell.AppActivate('microsoft-edge'); # Activate on EDGE browser
$wshell.SendKeys('^+{TAB}'); # CONTROL+SHIFT+TAB
..to no prevail. Yes, the batch starts and opens Edge and applies the two addresses to two tabs but I can not figure out how to SendKeys to the application.
Any Tips or Pointers will be greatly appreciated. Thanks in advance.
I've tried many ways to send keys combination but the combination of ^+{TAB} seems always not work. I find a software called AutoHotkey which can achieve your goal.
You can first download the software and create a autohotkey script file named test.ahk, with following content:
send ^{TAB}
exit
Then run the test.ahk in bat file:
#echo off
start microsoft-edge:"https://stackoverflow.com"
start microsoft-edge:"https://google.com"
timeout 2
$wshell=New-Object -ComObject wscript.shell;
$wshell.AppActivate('microsoft-edge');
"C:\Program Files\AutoHotkey\AutoHotkey.exe" "C:\Users\username\Desktop\test.ahk"
Please notice to replace the path with your own path. I've tested it and this could be a workaround.

Using start command in msconfig

The following command works just great as the only line in a batch file:
start "Google Sync" /belownormal "C:\Program Files\Google\Drive\googledrivesync.exe" /autostart
When I drop that line into msconfig startup tab, however, nothing happens.
So I thought maybe I needed to put in the full path to start.exe. Assuming it was an exe, that is.
So I tried both DIR and WHERE to locate start.* but nothing came up.
So, two 2uestions.
Is start a separate START.EXE executable in W7Pro and if so where is it?
How can I get this line to work inside msconfig?
Before you ask, my underlying purpose is to start Google Backup and Sync in the same way it usually does, but with /BELOWNORMAL priority. I already tried adding /BELOWNORMAL to the line Google was originally using in msconfig, without success. But START does what I want from a batch file and so I assume it would, or should, work via msconfig.
Thanks.
If you want to use commands implemented by Cmd.exe you must invoke Cmd.exe:
cmd /c start "Google Sync" /belownormal "C:\Program Files\Google\Drive\googledrivesync.exe" /autostart

Batch file to open fullscreen website

How do you open a website from startup, that'll run in fullscreen mode as well?
Using /max doesn't seem to do anything. That's for maximizing the screen. I want it to be like when F11 is pressed when you visit a website.
This is my file
#echo off
start chrome --profile-directory="Profile 1" "https://stackoverflow.com/"
I've also looked into automatically having a key typed, but I can't get it to work. This is my first dabble with batch-file. Maybe it'll help you though:
WScript.CreateObject("WScript.Shell").SendKeys("{F11}");
EDIT:
The answer to this similar question isn't what helped me. As I've stated, /max is just to maximize the screen, whereas I want it to go fullscreen.
To send keys exactly to the window you want you have to focus on it first with AppActivate function.The sendKeys.bat do both with a single script
here's an example (at the moment I have no chrome driver so I'm using the standard chrome):
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" "http://stackoverflow.com/"
call sendKeys.bat "Stack" "{F11}"
the first argument is the title and the second the keys to be send.
According to this list --start-fullscreen argument should also work
Here are a few ways to do this.
start "" "iexploerer.exe" -k "https://someurl.com"
start "" "chrome.exe" -kiosk "https://someurl.com"
start "" "firefox.exe" -kiosk "https://someurl.com"

Open multiple Microsoft Edge windows from batch file

I need to open 2 Edge windows from a batch file (not two tabs, 2 windows). I know I can launch edge using the following command:
start microsoft-edge:
But if I try it twice the second command does nothing. If I try it with URLs I get 2 tabs in the same window. e.g.
start microsoft-edge:http://google.com
start microsoft-edge:http://bing.com
Any ideas how to get 2 separate windows?
Use --new-window option:
start msedge http://google.com
start msedge --new-window http://bing.com
As you are aware, you can trigger Microsoft Edge indirectly from the command line (or a batch file) by using the microsoft-edge: protocol handler. Unfortunately, this approach doesn't enable you to open up an arbitrary number of windows.
The Microsoft Edge team built a small utility to assist, and presently hosts it on GitHub.
> MicrosoftEdgeLauncher.exe http://bing.com
> MicrosoftEdgeLauncher.exe http://stackoverflow.com
I just tested this, and it opened two individual windows for me. There does appear to be an issue where the second window doesn't navigate to the URL; remaining open with the New Tab Page.
You can open as many as you like, just create batch files that call other batch files.
Very easy to do.
Ex: batch1.cmd:
#echo off
start microsoft-edge:http://google.com
start "path\batch2.cmd"
exit
Make sure to add "start microsoft-edge:http://bing.com" on your "batch2.cmd" file
Manny
You can use the executable msedge_proxy.exe which is installed alongside msedge.exe. For example in "C:\Program Files (x86)\Microsoft\Edge\Application".
Sample usage:
> msedge_proxy.exe --app=http://bing.com
If you execute that command multiple times, it pops a new window each time.

Locking focus on batch file

I have a simple batch file in windows that I run on startup that presents the user with a menu to start certain applications. However by default, whenever I open one of these applications the focus goes to that window and off of the batch file. Is there a way to maintain, or re-divert focus onto the batch window?
Thanks
EDIT: Got it to do what I wanted. Used foxidrives suggestion to start them minimized but they were still taking focus. So I made a short VBScript to make the cmd window the active window after each call and the combination of the two worked. Thanks!
There is no command to steal the focus. As Bill_Stewart posted, that would be a dangerous feature that grants the program too much power over the user. You can however start the applications minimized (they will still be the active window), and then build and call a VBScript to make your batch window the active window:
start "" /MIN "application.exe"
cscript /nologo myVBScript.vbs
myVBScript.vbs
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.AppActivate "myBatchFile"
WScript.Sleep 2000
WshShell.AppActiavte "myBatchFile"
I've read that several people have had trouble with AppActivate on Windows 7. It was not functioning for me, and instead of bringing my target window to the foreground it just blinked in the task bar. Calling it a second time however, for some reason, brought it to the foreground and made it the active window, which is what I wanted. Hope this helps anybody else with a similar issue.
you can't lock the focus to your command prompt window. But what you could do is to set the TopMost flag of the command prompt window. There is a Win32 function called SetWindowPos which does that. Maybe there are some ready to use command line tools around which are doing this for you. Or, if you have visual studio installed, try to compile this one here: How to set a console application window to be the top most window (C#)?
If you use the start command with the /min switch then the application will be minimised and the batch file should remain visible:
#echo off
pause
echo launching notepad
start "" /min notepad
echo notepad is active
pause

Resources