Jump to content

Launching Chrome with Command Line Switches

Recommended Posts

Hi All

I'm not sure what I'm doing wrong here. I am trying to pass a URL to chrome and launch it with a command line switch using ShellExecute. I've also tried Run but neither of them seem to work as soon as I introduce the switches I need to use: --no-first-run --no-default-browser-check

I've been trying to get just --no-first-run to work before adding the other one but I can't and I don't know what I'm doing wrong.

If I run this from Windows Run, it works: C:\Program Files (x86)\google\chrome\application\chrome.exe --no-first-run google.com

Here is the code I'm trying to use:

If $CmdLine[0] = 2 then

    $arg    = $CmdLine[1]
    $link     = $CmdLine[2]

ShellExecute("chrome.exe", $arg & " " & $link, '"C:\Program Files (x86)\Google\Chrome\Application\"' )
;Run ('"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"' & " " & '"--no-first-run"' & " " & $link)

I am calling it like this: runchrome.exe --no-first-run google.com

If I don't try to use $arg and just use $link for ShellExecute, chrome launches to the URL, no problem. The commented out Run also doesn't work but will if I don't try to use the switch. 

Any help would be appreciated.

*Edit: What I mean by "doesn't work" is that chrome doesn't seem to launch at all.

Edited by ottawamona
Link to post
Share on other sites

I think it had to do with the way I was building the string. I cleaned it up and it looks like this now 

$linktorun = '"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --no-first-run --no-default-browser-check ' & $link
Run ($linktorun)
Run ($linktorun)

For some strange reason, Chrome wants to shut down on the first launch so I'm launching it twice. That may have to do with the switches I'm using but at least it's launching now.

Link to post
Share on other sites

Hi & welcome to the forum!

I have no idea what --no-first-run does so I tried it here with --incognito, seems to work.
My guess would be that the command line parameters to your script don't get passed properly.

Put this at the beginning at your script and post the output:

Global $FullCmdLine

If $CmdLine[0] > 0 Then
    For $i = 1 To $CmdLine[0]
        $FullCmdLine &= "(" & $i & ")" & $CmdLine[$i]

MsgBox(0, "", $FullCmdLine)


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...