powershell to run firefox

Discussions and Tech Support related to automating the iMacros Browser or Internet Explorer from any scripting and programming language, such as VBS (WSH), VBA, VB, Perl, Delphi, C# or C++.

Moderators: Community Moderators, iMacros Moderators

Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the Google search box (at the top of each forum page) to see if a similar problem or question has already been addressed. This will search the entire contents of the forums as well as the iMacros Wiki.
3. We can respond much faster to your posts if you include the following information:

CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST

Answering your own posts (e.g. attempting to "bump" your topic) drops your topic from the list of unanswered threads, so it may actually receive less views.

powershell to run firefox

by les_stockton on Sat Dec 05, 2015 12:10 pm

I'm having a problem with the latest version of Firefox along with the latest version of imacros. It crashes after running a couple of my imacros scripts. It doesn't matter which scripts I run. It will crash.

To solve this, I built a Powershell script to launch individual instances of Firefox, one at a time, and issue a command to run one imacros script. Upon completion, the powershell script will remove that job, and issue another command to launch a new instance of Firefox and run another imacros script.

I get the following error from iMacros:
iMacros run command: macro C:\Users\stockton\Documents\iMacros\Macros\JrOilers_v_Blazers-2015.12.04.iim not found (Error code: -930)

does it think that the command includes the word "macro" up front? Because the path for the iim file is correct.
Here's the powershell loop for issueing the command:

Code: Select all
   foreach($imacroFile in $iMacrosFiles) {
      Try
      {
         $args = -join ("imacros://run/?m=", $imacroFile)
         Write-Host $args
         $job = Start-Job -name "Firefox flickr" -ScriptBlock { & 'C:\Program Files (x86)\Mozilla Firefox\firefox.exe' @args } -ArgumentList $args

         Wait-Job $job
         Receive-Job $job
         $job | Remove-Job
      }
      Catch
      {
      }
   }
les_stockton
 
Posts: 19
Joined: Sun Mar 06, 2011 4:30 pm

Re: powershell to run firefox

by chivracq on Sat Dec 05, 2015 1:32 pm

les_stockton wrote:I'm having a problem with the latest version of Firefox along with the latest version of imacros. It crashes after running a couple of my imacros scripts. It doesn't matter which scripts I run. It will crash.

To solve this, I built a Powershell script to launch individual instances of Firefox, one at a time, and issue a command to run one imacros script. Upon completion, the powershell script will remove that job, and issue another command to launch a new instance of Firefox and run another imacros script.

I get the following error from iMacros:
iMacros run command: macro C:\Users\stockton\Documents\iMacros\Macros\JrOilers_v_Blazers-2015.12.04.iim not found (Error code: -930)

does it think that the command includes the word "macro" up front? Because the path for the iim file is correct.
Here's the powershell loop for issueing the command:

Code: Select all
   foreach($imacroFile in $iMacrosFiles) {
      Try
      {
         $args = -join ("imacros://run/?m=", $imacroFile)
         Write-Host $args
         $job = Start-Job -name "Firefox flickr" -ScriptBlock { & 'C:\Program Files (x86)\Mozilla Firefox\firefox.exe' @args } -ArgumentList $args

         Wait-Job $job
         Receive-Job $job
         $job | Remove-Job
      }
      Catch
      {
      }
   }

FCIM...! :mrgreen:
Mention your exact FCI for me to do any digging..., "latest version" is always vague as you always have 3 "latest versions" for FF and 1-2-3-4 "latest versions" for iMacros, which gives about 10 different possible Configurations to choose from...

First time I see such a PowerShell Script, so I've never used such a Script, but I guess I can try to run it... well, if you post your Full Script at least, to be able to try to reproduce your Pb..., I don't see how '$iMacrosFiles' for example is defined...

You could try as well if you get the same Problem using a "standard" .BAT File, there are several Examples of Batch Files on the Forum, I've published my working one several times already...
Last edited by chivracq on Sat Dec 05, 2015 4:51 pm, edited 1 time in total.
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6472
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: powershell to run firefox

by les_stockton on Sat Dec 05, 2015 1:51 pm

The Firefox I have running is 42.0
I have iMacros for Firefox version 8.9.4
OS is Windows 7

The iim scripts that I have have ran for years with no problem. I'm running copies of them with mods, but I still have the problem even if I run only old ones.

I was just wondering if there's something special I need to do to either update the extension somehow,
or if there's an answer to why the command line start can't find the iim files. I have the path. It even tells me the path in the error message. But I was puzzled with how it prefixes with 'macro' before echoing the file path. I would assume that this is documenting the fact that this is the path to the macro file, but I wasn't certain.

The powershell runs Firefox and issues the command, but it's just that Firefox/iMacros can't seem to find the macro file, even when specified with a full path.
les_stockton
 
Posts: 19
Joined: Sun Mar 06, 2011 4:30 pm

Re: powershell to run firefox

by les_stockton on Sat Dec 05, 2015 2:36 pm

The actual string that gets displayed in the Firefox address window is:
imacros://run/?m=C:\Users\stockton\Documents\iMacros\Macros\example.iim


is this imacros://run command correct?
les_stockton
 
Posts: 19
Joined: Sun Mar 06, 2011 4:30 pm

Re: powershell to run firefox (solved)

by les_stockton on Sat Dec 05, 2015 2:44 pm

Figured it out. There is no reason to specify the path to the iim file.
les_stockton
 
Posts: 19
Joined: Sun Mar 06, 2011 4:30 pm

Re: powershell to run firefox (solved)

by chivracq on Sun Dec 06, 2015 2:23 am

les_stockton wrote:Figured it out. There is no reason to specify the path to the iim file.

OK, Thanks for updating your Thread of course with the Final Solution, I don't use the Full Path either in my .BAT Files, but hum..., I would expect them to work as well if I specified the Full Path...

I would still be interested if you could post your Full PowerShell Script...

And your original Pb about your Macros crashing after a few running is a bit strange..., you managed to find a Workaround, but it still is not normal...
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6472
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)


Return to Scripting and Command Line Interface

Who is online

Users browsing this forum: No registered users and 2 guests

-->