Jump to content

How to pass parameters from xml to auto it script? - (Moved)


Sankesh
 Share

Recommended Posts

No its still not working..tried the below code and folder Program Filesxxxx\Socrates\Logs is getting created. But I want to create a folder inside an existing folder :(

 

#RequireAdmin
Global $a
Global $dir = "C:\Program Files\Socrates"
   If $dir = -1 Then
        MsgBox($MB_SYSTEMMODAL, "", "Specified Directory doesn't exist")
        Exit
     Else
        $a=Dircreate("C:\Program Filesxxxx\Socrates\Logs")
    EndIf

 

Link to comment
Share on other sites

Good evening Francesco,

There is  a requirement where i believe that can be done through autoIT itself. but donno how to write code for that..

i have to update few values in the config files .

1.i have the values stored in a variable.

2.i have to check config file(config file path should be given as input by the user) ..if the value stored in the above variable already exists...then script should not update it..if not it have to update.

Seen functions like string replace of..but problem is i have double quotes in my config file.

 

eg:

1.closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="04:10:00" sendTimeout="04:10:00" transactionFlow="false"

in the above line i have to change the timeout values to 05:00:00,05:00:00,10:00:00,10:00:00.

2.  <file type="log4net.Util.PatternString" value="C:\Program Files\Socrates\Logs\Reena desktop server%property{MachineName}%property{UserName}.log" />

in the above line i have to check log file generating inside logs folder or not..if it is not i have to update so that log wil get generated inside log.

 

Thanks Francesco :)

 

 

Link to comment
Share on other sites

8 minutes ago, Sankesh said:

closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="04:10:00" sendTimeout="04:10:00" transactionFlow="false"

How do you intend to set values?

8 minutes ago, Sankesh said:

<file type="log4net.Util.PatternString" value="C:\Program Files\Socrates\Logs\Reena desktop server%property{MachineName}%property{UserName}.log" />

%property{PropertyName} are replaced by you?

Edited by FrancescoDiMuro

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

1.Yeah we have to set the closetimeout values manually..i am planning to set that value through script.

2.%property{PropertyName} are replaced by you?

No its not replaced..actaully that log wil get generated through installer. I have to change the path to "C:\Program Files\Socrates\Logs\xxxxxxxx.

 

Link to comment
Share on other sites

@Sankesh
You could use something like this:

#include <Array.au3>
#include <StringConstants.au3>

Global $strFirstString = 'closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="04:10:00" sendTimeout="04:10:00" transactionFlow="false"', _
       $strSecondString = ' <file type="log4net.Util.PatternString" value="C:\Program Files\Socrates\Logs\Reena desktop server%property{MachineName}%property{UserName}.log" />', _
       $arrResult[0][2], _
       $strPath = "C:\\SomePath\\SomeFile.log", _
       $varNewValue


_ArrayAdd($arrResult, StringRegExpReplace($strFirstString, '(\b[^=]+\b)="([^"]+)"\s?', '$1|$2' & @CRLF))
If @error Then
    ConsoleWrite("_ArrayAdd ERR: " & @error & @CRLF)
Else
    _ArrayDelete($arrResult, UBound($arrResult) - 1)

    ConsoleWrite("Values before: " & $strFirstString & @CRLF)

    For $i = 0 To UBound($arrResult) - 1 Step 1
        $varNewValue = InputBox("Set value:", "Parameter: " & $arrResult[$i][0], $arrResult[$i][1])
        If $varNewValue <> "" Then $strFirstString = StringRegExpReplace($strFirstString, _
                                                                         $arrResult[$i][0] & "=" & '"' & $arrResult[$i][1] & '"', _
                                                                         $arrResult[$i][0] & "=" & '"' & $varNewValue & '"')
    Next

    ConsoleWrite("Values after : " & $strFirstString & @CRLF)
EndIf

ConsoleWrite("Path before: " & $strSecondString & @CRLF)
ConsoleWrite("Path after : " & StringRegExpReplace($strSecondString, 'value="[^"]+"', 'value="' & $strPath & '"') & @CRLF)

The path you want to replace has to contain double backslashes, since the \ is a metacharacter :)

Edited by FrancescoDiMuro

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...