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++.
Forum rules
iMacros EOL - Attention!

The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.

Thank you again for your business and support.

Sincerely,
The Progress Team

Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
les_stockton
Posts: 41
Joined: Sun Mar 06, 2011 11:30 pm

powershell to run firefox

Post by les_stockton » Sat Dec 05, 2015 7: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
		{
		}
	}
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: powershell to run firefox

Post by chivracq » Sat Dec 05, 2015 8: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 11:51 pm, edited 1 time in total.
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
les_stockton
Posts: 41
Joined: Sun Mar 06, 2011 11:30 pm

Re: powershell to run firefox

Post by les_stockton » Sat Dec 05, 2015 8: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: 41
Joined: Sun Mar 06, 2011 11:30 pm

Re: powershell to run firefox

Post by les_stockton » Sat Dec 05, 2015 9: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: 41
Joined: Sun Mar 06, 2011 11:30 pm

Re: powershell to run firefox (solved)

Post by les_stockton » Sat Dec 05, 2015 9:44 pm

Figured it out. There is no reason to specify the path to the iim file.
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: powershell to run firefox (solved)

Post by chivracq » Sun Dec 06, 2015 9: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)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Post Reply