2008-10-26

Chrome_Incognito.js

If you haven't updated to 0.3.154.9 this script may still be of use. But, with that version you can now append: ...chrome.exe" --incognito to your Google Chrome shortcut and it will start in Incognito mode by default.

Save snippet below to a file (call it something like Chrome_Incognito.js) in 'My Documents' folder or the desktop. Double-click this file, & it opens a chrome browser window, then, an incognito window, then, shuts first window...leaving you "incognito".

If you have trouble saving code snippits see notes here.


//Chrome_Incognito.js - start chrome incognito
var oSh=new ActiveXObject("WScript.Shell");
var liWait=1500;  //wait ms (double on older pc)
var Chrome_HKLM="HKLM\\"+
  "SOFTWARE\\"+
  "Classes\\"+
  "ChromeHTML\\"+
  "shell\\"+
  "open\\"+
  "command\\";
var Chrome=oSh.RegRead(Chrome_HKLM);
oSh.Run(Chrome); //start chrome
WScript.Sleep(liWait);
oSh.Sendkeys("^+N"); //start new incognito window
WScript.Sleep(liWait);
oSh.Sendkeys("%{Tab}"); //go previous(first) browser window
WScript.Sleep(liWait);
oSh.Sendkeys("%{F4}"); //close first browser window


...here it is in .vbs (VBScript):
'Chrome_Incognito.vbs - start chrome incognito
Set oSh=CreateObject("WScript.Shell")
Dim Chrome_HKLM
Chrome_HKLM="HKLM\" & _
  "SOFTWARE\" & _
  "Classes\" & _
  "ChromeHTML\" & _
  "shell\" & _
  "open\" & _
  "command\"
Dim Chrome
Chrome=oSh.RegRead(Chrome_HKLM)
oSh.Run Chrome
ccSleep 1
oSh.Sendkeys "^+N"
ccSleep 1
oSh.Sendkeys "%{Tab}"
ccSleep 1
oSh.Sendkeys "%{F4}"
WScript.Quit
'-
Sub ccSleep(seconds)
  set oShell = CreateObject("Wscript.Shell")
  cmd = "%COMSPEC% /c ping -n " & 1 + seconds & " 127.0.0.1>nul"
  oShell.Run cmd,0,1
End Sub
'-this ccSleep I got from : http://www.mvps.org/scripting/rube/index.htm
Notes:

The saved file icon should display as fancy-scroll "S". If not -- the editor may be "helping" by automatically adding(& hiding) the ".txt" extention. To get around save in double-quotes: "Chrome_Incognito.js" -- and the name with this extention should "stick".

If double-clicking the file opens it in the editor -- script "open" is interpreting as "open with editor" -- to get around: ctrl+shift+click to obtain a context menu that will have an "Open with..." option. Choose this - then choose: "Microsoft (R) Windows Based Script" (and check "always use..." -- if you prefer it).

In these scripts I'd originally specified Run("Chrome.exe") - didn't always work. I tried adding instructions to check properties/copy settings from Google Chrome launch short-cut, but, again, found this didn't work for some users.

These scripts read system registry to determine Chrome location, and, hopefully, remove implementation differences and need for manual edit.

P.s. I've seen notes on the internet of starting chrome with '--incognito' startup parm -- but, that doesn't appear to work (at least with Google Chrome version 0.2.149.30 - does starting with 0.3.154.9).

P.s.s. If brave - try putting the snippet below at bottom of the first .js script from above.

This combines "Incognito" and using Google servers as a proxy to hide IP address. Having IP address logged I find an annoyance. Some software programs assume things and take unwanted actions based on returning IP address.

P.s.s.s.  These scripts and techniques work for me. If you have concerns about other "research" going on - the PC can be placed in in a public area to encourage safe (vs. anonymous) browsing habits.
var sURL=
"http://translate.google.com/"+
"translate"+
"?ie=UTF-8"+
"&sl=es"+
"&tl=en"+
"&hl=en"+
"&u="+
"http://www.anonymouse.org";
WScript.Sleep(liWait);
oSh.Sendkeys("{F6}");//go addressbar
WScript.Sleep(liWait);
oSh.SendKeys(sURL+"{Enter}");//supply "google proxy"
WScript.Sleep(liWait);

Some have asked if there's a way to check if Chrome is already running. To do so --is more complicated see version #2

-Thanks/regards

6 comments:

Ryan J said...

I've been looking for a way to do this ever since Chrome came out.

Thank you!

Ed said...

Latest change did the trick.
Thank you very much.

gxg said...

It would be nice if the script could also check if there is a Chrome window opened and in this case didn't close it after opening the incognito window.

Anonymous said...

Hi
I had a spot of bother with the incognito.js script on my system, and I suspect many others. CHROME.EXE is not recognised by windows explorer on some Chrome installations, mine included, and I did nothing special during its installation (a very early version mind you).
So launching chrome.exe failed in the script as the shell couldn't find the full path to the EXE. I even tried putting in the full path in the script, that didn't work either strangely.
The solution -
Start -> Settings -> Control Panel -> System -> Advanced Tab -> Environment Variables button.
From here, find the PATH sys variable and add in the fully qualified name of the folder that Chrome lives in - semi-colon separated list of folders.
In my case this was in the user profile - have Google never heard of this thing called Roaming User Profiles in Windows domain environments??? Most notably the 30Mb GPO profile size limit, of which Chrome helps cause problems with. Thanks Google!
Anyway, afterwards, check to see if you can type CHROME.EXE into the Start -> Run box to see if chrome launches from the shell. The script should then work fine - it did for me anyway.
Good script though, but its nice to know I can use the --incognito switch now instead of faffing around. ;-)

Anonymous said...

Thanks Michael!

Time and again, it proves right, whenever I thought, something would be nice if provided!.. I ended up finding that over the Internet!

Thanks to you again!

movie buff said...

I hesitate to use even upgraded versions of Chrome, since my last experience using it (first version) left my computer compromised; have they fixed the security issues beyond all doubt?

LibriVox's New Releases

Blog Archive