ct253704

Multiple Command Issue - Cannot Find Specified Path

4 posts in this topic

I'm having some issues converting a batch file to be used in a script of mine. The batch file was pulled from Stack Overflow with small modifications and works by itself, but when I convert to AutoIT it gets about halfway through and then gives the error "Cannot find the path specified". All it does is set the firefox homepage, though i'd like to expand the settings altered in the prefs.js file if I can get this to work.

Batch File:

cd /D "%APPDATA%\Mozilla\Firefox\Profiles"
cd *.default*
set ffile=%cd%
cd %ffile%
echo user_pref("browser.startup.homepage", "https://www.google.com");>>"%ffile%\prefs.js"
set ffile=
cd %windir%

AutoIT Code

RunWait(@ComSpec & ' /k ' & 'cd /D "%APPDATA%\Mozilla\Firefox\Profiles"&&cd *.default*&&set ffile=%cd%&&cd %ffile%&&echo user_pref("browser.startup.homepage", "https://www.google.com");>>"%ffile%\prefs.js"&&set ffile=&&cd %windir%')

Also to note the batch file doesn't work if each line is ran individually via command prompt. Maybe I should change one of the && in the code?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I made this.

 

Local $sprefsPath=_FireFoxprefsPath()
Local $sString='user_pref("browser.startup.homepage", "https://www.google.com");'
FileWriteLine($sprefsPath, @Crlf & $sString)
Func _FireFoxprefsPath()
    Local $sPath = @AppDataDir & "\Mozilla\Firefox\"
    Return ($sPath & IniRead($sPath & "profiles.ini", "Profile0", "Path", "") & "\" & "prefs.js")
EndFunc

Saludos

Edited by Danyfirex
1 person likes this

Share this post


Link to post
Share on other sites

Bonus! That's a clever way to return the filepath. I'll test that out. May I ask what the @CRLF will do in this case, exactly? I've never used that macro. Does it just ensure that the "user pref" portion is put in a line of its own? 

Share this post


Link to post
Share on other sites

just for wirting in next line. look help file or do a google search.

Saludos

Share this post


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