As part of a console application, I'd like to hit a URL in Chrome without showing the browser window. Is this possible?
I'm already using /B with the command prompt:
start "" /B "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" "google.com"
You need vbscript to hide a window.
Set WshShell = WScript.CreateObject("WScript.Shell")
msgbox FormatNumber(WshShell.Run("cmd /k dir c:\windows\*.*", 0, false))
Something like
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run wscript.Arguments(0), 0, false
in a vbs file. Use
C:\Users\User>"C:\Users\User\Desktop\RunHidden.vbs" "notepad"
Related
i made a zip file containing a google chrome extension pack and made it "public" via a download link (lets say its http://someaddress.com/extension.zip).
Then, i looked a lot on stackoverflow and found multiple approaches to add this extension as "automatically" as possible (without publishing it on the google store).
I came up with this BATCH file:
#echo off
setlocal
cd /d %~dp0
set dwURI="http://someaddress.com/extension.zip"
set tpZIP="%temp%\extension.zip"
call :DownloadFile %dwURI% %tpZIP%
call :UnZipFile "%AppData%" %tpZIP%
del "%temp%\extension.zip"
taskkill /f /im "chrome.exe"
start chrome --load-extension="%AppData%\extension"
start "%AppData%\extension"
exit /b
:UnZipFile <ExtractTo> <newzipfile>
set vbs="%temp%\unzip.vbs"
if exist %vbs% del /f /q %vbs%
>%vbs% echo Set fso = CreateObject("Scripting.FileSystemObject")
>>%vbs% echo If Not fso.FolderExists(%1) Then
>>%vbs% echo fso.CreateFolder(%1)
>>%vbs% echo End If
>>%vbs% echo set objShell = CreateObject("Shell.Application")
>>%vbs% echo set FilesInZip=objShell.NameSpace(%2).items
>>%vbs% echo objShell.NameSpace(%1).CopyHere(FilesInZip)
>>%vbs% echo Set fso = Nothing
>>%vbs% echo Set objShell = Nothing
cscript //nologo %vbs%
if exist %vbs% del /f /q %vbs%
:DownloadFile <URL> <DownloadTo>
bitsadmin /transfer mydownloadjob /download /priority FOREGROUND %1 %2
cls
To actually "install" the extension the command ended up beeing this one line start chrome --load-extension="%AppData%\extension" that sets the extension unpacked path to load.
My problem: it only loads the extension on that particular call. If i close chrome and open it again it's not there, it doesn't "auto load".
If i go to the appdata folder and install the unpacked extension on google chrome enableing the developer option and seeking that folder it stays "installed".
Is there a "--install-extension:" command on google chrome that i cannot find, or is there another way to order it do install it?
This is a follow-up question to Launching 2 Google Chrome windows in different positions and Launch Google Chrome from the command line with specific window coordinates.
Apart from what has already been said in those 2 posts, I am wondering if there is a command I can add to a batch file which allows me to open a new Chrome window scrolled down to a specific position, or by a specific "amount".
I have checked this page and this page but have not found anything.
Here I use sendkeys after opening chrome to open the console, focus on the console, and input some javascript to scroll 100px down.
#if (#CodeSection == #Batch) #then
#echo off
rem Use %SendKeys% to send keys to the keyboard buffer
set SendKeys=CScript //nologo //E:JScript "%~F0"
rem Start the other program in the same Window
call "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.sendkeys.send?view=netframework-4.8
timeout /t 2
%SendKeys% "^(+({J}))"
timeout /t 2
%SendKeys% "^(`)"
%SendKeys% "window.scrollBy{(}0, 100{)};~"
goto :EOF
#end
// JScript section
var WshShell = WScript.CreateObject("WScript.Shell");
WshShell.SendKeys(WScript.Arguments(0));
I want to launch a particular URL in chrome every day at the same time. How can I achieve this using command line?
There are two ways to do this. The first being from a single command line. You will want to create a new task in Task Scheduler and have it run a command at a desired time. If you wish to use a different browser that supports command lines, be sure to use _ for any spaces in the directory path.
Command line:
SchTasks /Create /SC DAILY /TN "New_Task" /TR "start "C:\Program_Files_(x86)\Google\Chrome\Application\chrome.exe" www.stackoverflow.com" /ST 09:00
The second option is to use a batch file you store somewhere and it will be called to using the SchTasks. Simply create the site1.bat and place it somewhere safe example C:\Windows\My Tasks.
From Batch:
#ECHO OFF
#set Task_Name=Task1
#Set Time=09:00
#set Site=www.stackoverflow.com
schtasks /query /TN "%Task_Name%" >NUL 2>&1
IF %ERRORLEVEL% EQU 0 (goto :EXISTS) ELSE (goto :CREATE)
:CREATE
Set Folder=%~dp0
Set Name=%~nx0
Echo Task does not already exist, creating it now.
SchTasks /Create /SC DAILY /TN "%Task_Name%" /TR "%Folder%%Name%" /ST %Time%
goto :eof
:EXISTS
start "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" %Site%
goto :eof
I would like to launch a MS Access macro from the command line (it's being run from another tool) to generate an output. Thing is, I'd prefer it if it could supress access from loading it's interface. I just want it to run the macro and shut down. Any thoughts on how to do this?
I've used a command line something like this so far:
"C:\Program Files (x86)\Microsoft Office\Office14\MSACCESS" "S:\filepath\Database\database.accdb" /x Macro1
You can use COM automation from VBScript to create an Access application instance, hide it from view, run your macro, and then shut down Access.
I saved the following script as RunAccessMacro.vbs and ran it in a command prompt window using this as the command line ...
cscript //NoLogo C:\share\vbscript\RunAccessMacro.vbs
This is RunAccessMacro.vbs ...
Option Explicit
Const cstrDbFile = "C:\share\Access\database1.mdb"
Dim accessApp
Set accessApp = CreateObject("Access.Application")
accessApp.Visible = False
accessApp.OpenCurrentDataBase cstrDbFile, False ' open shared
accessApp.DoCmd.RunMacro "Macro1"
accessApp.Quit
Set accessApp = Nothing
I need to browse a URL using Internet Explorer, and close using taskkill through TCL script. I am using following TCL script for this.
My TCL Script:
set data [open input_url.txt r]
set test [read $data]
foreach url $test {
exec "C:/Program Files/Internet Explorer/IEXPLORE.EXE" $url
after 2000
exec "C:/WINDOWS/System32/taskkill.exe" /IM IEXPLORE.EXE /F
}
input_url.txt content:
clickshare upload.com upload.to 10upload.com 123upload.pl 139pan.com 163pan.com
But When I run this script, Browser with first URL is opened. But nothing is happening after this. After 2-3 minutes, if I close the browser manually, I am seeing the following error:
C:\Users\kumar\Desktop\test>tclsh stack_question.tcl
child process exited abnormally
while executing
"exec "C:/Program Files/Internet Explorer/IEXPLORE.EXE" $url"
("foreach" body line 2)
invoked from within
"foreach url $test {
exec "C:/Program Files/Internet Explorer/IEXPLORE.EXE" $url
after 2000
exec "C:/WINDOWS/System32/taskkill.exe" /IM IEXPLO..."
(file "stack_question.tcl" line 3)
C:\Users\kumar\Desktop\test>
I am able to kill the browser session manually using taskkill.exe as shown below:
C:\Users\kumar\Desktop\test>tclsh
% exec "C:/WINDOWS/System32/taskkill.exe" /IM IEXPLORE.EXE /F
SUCCESS: The process "iexplore.exe" with PID 3948 has been terminated.
SUCCESS: The process "iexplore.exe" with PID 3744 has been terminated.
%
Could any one please help me to fix this issue?
Thanks in advance.
It seems like exec is waiting for iexplore.exe to finish before it continues execution. In order to allow immediate return use start command:
exec cmd.exe /c start iexplore.exe $url
This will return immediately.