Jump to content

Running firefox in private mode with URL


Go to solution Solved by Xenobiologist,

Recommended Posts

Hello guys,

I 've written a little application in Autoit which starts IE or firefox with a html file which is generated before. The file contains the URL which shall be started.

What I'm trying to do is start firefox in private mode and directly load the file.

This doesn't work. All I have done successfully is start firefox in private mode and then "ControlSend" the complete filename (path) and hit enter.

Then firefox transforms the path into the file:/// ... syntax and loads the url.

This works, but using ControlSend isn't the best way, because it sometimes fails when a sign gets lost during send-process.

Does anybody know an option to just use an Autoit command to run a private window with the given filename (path)?

The exact call looks this way at the moment:

                ShellExecute(@ProgramFilesDir & '\Mozilla Firefox\firefox.exe ', '-private-window ', @ProgramFilesDir)
;~                 ShellExecute(@ProgramFilesDir & '\Mozilla Firefox\firefox.exe ', ' -private-window' & ' -url file:///' & StringReplace($filename, '\', '/'), @ProgramFilesDir)
                ConsoleWrite('private Mode FF' & @CRLF)
                Local $ff_handle = WinWaitActive('Privater Modus - Mozilla Firefox (Privater Modus)', '', 5)
                Sleep(100)
;~                 Opt('SendAttachMode', 1)
                Opt('SendKeyDelay', 5)
                Opt('SendKeyDownDelay', 1)
                ControlFocus($ff_handle, '', '')
                ControlSend($ff_handle, '', '', $filename & '{ENTER}')

The file looks like this:

<html>
    <head>
        <title> Reporting-Manager ANMELDUNG </title>
    <script>
        function createCookie(name, value, days) {
            if (days) {
            var date = new Date();
            date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
            var expires = "; expires=" + date.toGMTString();
        }
            else var expires = "";
            document.cookie = name + "=" + value + expires + ";domain=.dsp-mgY.gaxeg.de;path=/cognos01";
    }

        function eraseCookie(name) {
        createCookie(name, "", -1);
}

            function logMeIn(){ 
                window.opener=null;
                eraseCookie("cc_session");
                eraseCookie("caf");
                eraseCookie("cam_passport");
                eraseCookie("userCapabilities");
                eraseCookie("CRN");
                eraseCookie("CGC");
                eraseCookie("usersessionid");
                eraseCookie("cea-ssa");

                document.getElementById("formLogin").submit();
            };

            onload = function() {
                        logMeIn();
                     }

    </script>
</head>
<body>
<form style="margin:0px;padding:0px;" method="post" action="http://dsp-mgY.gaxeg.de/cognos01/cgi-bin/cognos_module" name="pform" id="formLogin">
    <input type="hidden" name="b_action" value="xts.run" id="inputBaction">
    <input type="hidden" name="startwel" value="yes" id="inputStartwel">
    <input type="hidden" name="m" value="portal/main.xts" id="inputM">
    <input type="hidden" name="h_CAM_action" value="logonAs">
    <input type="hidden" name="CAMNamespace" value="ldap" id="inputCamNamespace">
    <input type="hidden" name="CAMUsername" value="xxx" id="CAMUsername">
    <input type="hidden" name="CAMPassword" value="xxx" id="CAMPassword">
    <input type="hidden" name="bank21.funktionsmandant" value="0112" id="bank21.funktionsmandant">

    <div style="width: 150px; height: 50px; margin-left: auto; margin-right: auto; margin-top: 300px; text-align: center">
        <img src="http://dsp-mgY.gaxeg.de/cognos01//ps/portal/images/icon_loading.gif" width="32" height="32"/><br/><br/>
        Bitte warten<br/><br/>
        Anmeldung an Reporting ...
    </div>
</form>
</body>
</html>

Thanks for any help.

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

You mean this?

ShellExecute(@ProgramFilesDir & '\Mozilla Firefox\firefox.exe ', $filename & ' -private-window ', @ProgramFilesDir)

This leads to a normal firefox window in which the automatic login from the file happens and to a second firefox window. The second is private but doesn't start any URL or something else. 

 

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Sorry, I meant that the "-url" parameter is not necessary, because the url itself is a parameter :

ShellExecute(@ProgramFilesDir & '\Mozilla Firefox\firefox.exe ', ' -private-window' & ' file:///' & StringReplace($filename, '\', '/'), @ProgramFilesDir)
Link to comment
Share on other sites

I tried that before. Same behauviour. Firefox opens two windows.

1 - with the login is NON-Private

2 - private-mode window without any further action (like start new tab in private mode)

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

I created a new script with just this one line

ShellExecute("C:\Program Files (x86)\Mozilla Firefox\firefox.exe", ' -private-window' & ' file:///' & StringReplace("C:\Users\xf01145\AppData\Local\Temp\bank21-Reporting-Manager.html", '\', '/'), @ProgramFilesDir)

File is opened in normal mode and there is an additional window opened in private mode . :mad2:

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

I have to use 24 the last long time support version.

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

OK, I will try it tomorrow at work (with 24 ESR too).

If you cannot do it with the -private-window launching option, another way could be to use a temporary FF profile to do the same thing than a private browsing.

ShellExecuteWait(@ProgramFilesDir & '\Mozilla Firefox\firefox.exe ', '-profile "' & @TempDir & "\temporaryProfile" & '" http://www.google.com', @ProgramFilesDir)
DirRemove(@TempDir & "\temporaryProfile", 1)

But sure, it's less clean...

Link to comment
Share on other sites

Well, I reproduce the same issue at work with the version 24 (ESR). It's a know issue, which seems to be corrected with some last versions...

Here is a link for a conversation about the same thing : http://forums.mozillazine.org/viewtopic.php?f=38&t=2734967.

If you have to use a long time supported version, the next release (31 ESR) is on rails, scheduled for July (https://www.mozilla.org/en-US/firefox/organizations/faq/)

You can also try with my previous code, which use a temporary profile (equivalent to a private browsing).

Link to comment
Share on other sites

Ah thanks, so it is a bug in firefox. I tried the example with the temp profile. Same result as before.

So, I will keep the ControlSend solution until we update to version 31.

Thanks!

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

  • 1 month later...
  • Solution

Problem solved with firefox 31 the bug is gone.

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
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
 Share

×
×
  • Create New...