Loading
assing [ComputerName] to szLine parameter
hii...

 

i want to assign or say pass [computerName] to parameter szLine of

 

predefine function EzBatchAddString (szLine, szRefKey, nOptions).

 

i want to do it because i want to set the environment variable in batch file to

 

this value(ComputerName)

 

But when i set

 

szline=[ComputerName]

 

or

 

szLine=ComputerName

 

the compiler complaints for an error...

 

can u plz tell me how can i achieve this.

 

thanks

 

jagjit

  • I would suggest to first retrieve the value of ComputerName environment variable in a string and then pass it on to another function. Use GetEnvVar function to resolve the environment variable value:

     

    GetEnvVar("ComputerName", sCompName);

     

    Then use sCompName like any other variable in the Ez functions.
    Expand Post
  • hi

     

    when i added this function into my code..upon compilation i encountered 50 errors

     

    this is my code

     

    can u plz tell me where's the error

     

    include "ifx.h"

     

    export prototype MyFunction(HWND);

     

    STRING szLine, szRefKey;

     

    NUMBER nOptions;

     

    STRING sCompname

     

    function MyFunction(hMSI)

     

    // To Do: Declare local variables.

     

    begin

     

    define BATCH_FILE "C:\\ISExampl.bat"

     

    // Include Ifx.h for built-in InstallScript function prototypes.

     

    GetEnvVar("ComputerName",sCompname);

     

    // Set the default batch file.

     

    BatchSetFileName (BATCH_FILE);

     

    // Set up parameters for next call to EzBatchAddString.

     

    szLine = "rem This is the first line of the file.";

     

    szRefKey = "";

     

    nOptions = BEFORE|NOSET;

     

    // Add a comment line to the top of the batch file.

     

    if (EzBatchAddString (szLine, szRefKey, nOptions) < 0) then

     

    MessageBox ("First call to EzBatchAddString failed.", SEVERE);

     

    else

     

    MessageBox ("First call to EzBatchAddString successful.", INFORMATION);

     

    endif;

     

    // Set up parameters for next call to EzBatchAddString.

     

    szLine = "TEMP=C:\\EXAPP3";

     

    szRefKey = "PATH";

     

    nOptions = AFTER;

     

    // Add a line after the PATH statement.

     

    if (EzBatchAddString (szLine, szRefKey, nOptions) < 0) then

     

    MessageBox ("Second call to EzBatchAddString failed.", SEVERE);

     

    else

     

    MessageBox ("Second call to EzBatchAddString successful.", INFORMATION);

     

    endif;

     

    // Set up parameters for next call to EzBatchAddString.

     

    szLine = "C:\\EXAPP3\\EXAPP.EXE";

     

    szRefKey = "TEMP";

     

    nOptions = AFTER|NOSET;

     

    // Add a command line after the SET TEMP statement.

     

    if (EzBatchAddString (szLine, szRefKey, nOptions) < 0) then

     

    MessageBox ("Third call to EzBatchAddString failed.", SEVERE);

     

    else

     

    MessageBox ("Third call to EzBatchAddString successful.", INFORMATION);

     

    endif;

     

    // Set up parameters for next call to EzBatchAddString.

     

    szLine = "PATH=C:\\;C:\\Windows";

     

    szRefKey = "PATH";

     

    nOptions = AFTER|NOSET|REPLACE|COMMAND;

     

    // Replace the PATH statement.

     

    if (EzBatchAddString (szLine, szRefKey, nOptions) < 0) then

     

    MessageBox ("Fourth call to EzBatchAddString failed.", SEVERE);

     

    else

     

    MessageBox ("Fourth call to EzBatchAddString successful.", INFORMATION);

     

    endif;

     

    //endprogram

     

     

    end;
    Expand Post
  • these are the errors which i encountered when i jst added these two lines in the code

     

    STRING sCompname

     

    GetEnvVar("ComputerName",sCompname);

     

     

    following are errors generated only by the addition of these two lines in the code

     

     

    InstallShield Script Compiler

     

    Version 14.0.0.162

     

    Copyright 1997-2006 Macrovision Europe Ltd. and/or Macrovision Corporation. All Rights Reserved.

     

    Compiling...

     

    setup.rul

     

    C:\InstallShield 2008 Projects\My Project Name-4\script files\setup.rul(48) : error C8022: 'STRING' : comma or semicolon expected

     

    C:\InstallShield 2008 Projects\My Project Name-4\script files\setup.rul(61) : error C8022: 'function' : comma or semicolon expected

     

    C:\InstallShield 2008 Projects\My Project Name-4\script files\setup.rul(83) : error C8017: 'szRefKey' : expected typedef (struct) name

     

    C:\InstallShield 2008 Projects\My Project Name-4\script files\setup.rul(83) : error C8008: '=' : identifier expected

     

    C:\InstallShield 2008 Projects\My Project Name-4\script files\setup.rul(83) : error C8008: '' : identifier expected

     

    C:\InstallShield 2008 Projects\My Project Name-4\script files\setup.rul(84) : error C8017: 'nOptions' : expected typedef (struct) name

     

    C:\InstallShield 2008 Projects\My Project Name-4\script files\setup.rul(84) : error C8008: '=' : identifier expected

     

    C:\InstallShield 2008 Projects\My Project Name-4\script files\setup.rul(84) : error C8008: '1' : identifier expected

     

    C:\InstallShield 2008 Projects\My Project Name-4\script files\setup.rul(90) : error C8019: 'if' : expected type declaration

     

    C:\InstallShield 2008 Projects\My Project Name-4\script files\setup.rul(90) : error C8008: '(' : identifier expected

     

    C:\InstallShield 2008 Projects\My Project Name-4\script files\setup.rul(90) : error C8014: 'EzBatchAddString' : identifier already defined

     

    C:\InstallShield 2008 Projects\My Project Name-4\script files\setup.rul(90) : error C8025: 'szLine' : undefined identifier

     

    C:\InstallShield 2008 Projects\My Project Name-4\script files\setup.rul(90) : error C8014: 'szRefKey' : identifier already defined

     

    C:\InstallShield 2008 Projects\My Project Name-4\script files\setup.rul(90) : error C8014: 'nOptions' : identifier already defined

     

    C:\InstallShield 2008 Projects\My Project Name-4\script files\setup.rul(90) : error C8022: ')' : comma or semicolon expected

     

    C:\InstallShield 2008 Projects\My Project Name-4\script files\setup.rul(91) : error C8008: '0xFFFF0003' : identifier expected

     

    C:\InstallShield 2008 Projects\My Project Name-4\script files\setup.rul(91) : error C8022: ')' : comma or semicolon expected

     

    C:\InstallShield 2008 Projects\My Project Name-4\script files\setup.rul(92) : error C8019: 'else' : expected type declaration

     

    C:\InstallShield 2008 Projects\My Project Name-4\script files\setup.rul(93) : error C8014: 'MessageBox' : identifier already defined

     

    C:\InstallShield 2008 Projects\My Project Name-4\script files\setup.rul(93) : error C8038: 'First call to EzBatchAddString successful.' : numeric value required

     

    C:\InstallShield 2008 Projects\My Project Name-4\script files\setup.rul(93) : error C8008: '0xFFFF0001' : identifier expected

     

    C:\InstallShield 2008 Projects\My Project Name-4\script files\setup.rul(93) : error C8022: ')' : comma or semicolon expected

     

    C:\InstallShield 2008 Projects\My Project Name-4\script files\setup.rul(94) : error C8019: 'endif' : expected type declaration

     

    C:\InstallShield 2008 Projects\My Project Name-4\script files\setup.rul(97) : error C8017: 'szLine' : expected typedef (struct) name

     

    C:\InstallShield 2008 Projects\My Project Name-4\script files\setup.rul(97) : error C8008: '=' : identifier expected

     

    C:\InstallShield 2008 Projects\My Project Name-4\script files\setup.rul(97) : error C8008: 'TEMP=C:\EXAPP3' : identifier expected

     

    C:\InstallShield 2008 Projects\My Project Name-4\script files\setup.rul(98) : error C8017: 'szRefKey' : expected typedef (struct) name

     

    C:\InstallShield 2008 Projects\My Project Name-4\script files\setup.rul(98) : error C8008: '=' : identifier expected

     

    C:\InstallShield 2008 Projects\My Project Name-4\script files\setup.rul(98) : error C8008: 'PATH' : identifier expected

     

    C:\InstallShield 2008 Projects\My Project Name-4\script files\setup.rul(99) : error C8017: 'nOptions' : expected typedef (struct) name

     

    C:\InstallShield 2008 Projects\My Project Name-4\script files\setup.rul(99) : error C8008: '=' : identifier expected

     

    C:\InstallShield 2008 Projects\My Project Name-4\script files\setup.rul(99) : error C8008: '0' : identifier expected

     

    C:\InstallShield 2008 Projects\My Project Name-4\script files\setup.rul(102) : error C8019: 'if' : expected type declaration

     

    C:\InstallShield 2008 Projects\My Project Name-4\script files\setup.rul(102) : error C8008: '(' : identifier expected

     

    C:\InstallShield 2008 Projects\My Project Name-4\script files\setup.rul(102) : error C8014: 'EzBatchAddString' : identifier already defined

     

    C:\InstallShield 2008 Projects\My Project Name-4\script files\setup.rul(102) : error C8025: 'szLine' : undefined identifier

     

    C:\InstallShield 2008 Projects\My Project Name-4\script files\setup.rul(102) : error C8014: 'szRefKey' : identifier already defined

     

    C:\InstallShield 2008 Projects\My Project Name-4\script files\setup.rul(102) : error C8014: 'nOptions' : identifier already defined

     

    C:\InstallShield 2008 Projects\My Project Name-4\script files\setup.rul(102) : error C8022: ')' : comma or semicolon expected

     

    C:\InstallShield 2008 Projects\My Project Name-4\script files\setup.rul(103) : error C8008: '0xFFFF0003' : identifier expected

     

    C:\InstallShield 2008 Projects\My Project Name-4\script files\setup.rul(103) : error C8022: ')' : comma or semicolon expected

     

    C:\InstallShield 2008 Projects\My Project Name-4\script files\setup.rul(104) : error C8019: 'else' : expected type declaration

     

    C:\InstallShield 2008 Projects\My Project Name-4\script files\setup.rul(105) : error C8014: 'MessageBox' : identifier already defined

     

    C:\InstallShield 2008 Projects\My Project Name-4\script files\setup.rul(105) : error C8038: 'Second call to EzBatchAddString successful.' : numeric value required

     

    C:\InstallShield 2008 Projects\My Project Name-4\script files\setup.rul(105) : error C8008: '0xFFFF0001' : identifier expected

     

    C:\InstallShield 2008 Projects\My Project Name-4\script files\setup.rul(105) : error C8022: ')' : comma or semicolon expected

     

    C:\InstallShield 2008 Projects\My Project Name-4\script files\setup.rul(106) : error C8019: 'endif' : expected type declaration

     

    C:\InstallShield 2008 Projects\My Project Name-4\script files\setup.rul(109) : error C8017: 'szLine' : expected typedef (struct) name

     

    C:\InstallShield 2008 Projects\My Project Name-4\script files\setup.rul(109) : error C8008: '=' : identifier expected

     

    C:\InstallShield 2008 Projects\My Project Name-4\script files\setup.rul(109) : error C8008: 'C:\EXAPP3\EXAPP.EXE' : identifier expected

     

    C:\InstallShield 2008 Projects\My Project Name-4\script files\setup.rul(109) : fatal error F8516: maximum error count reached

     

    Setup.inx - 51 error(s), 0 warning(s)
    Expand Post
  • Community Manager (Flexera Software)

    You'll want to add a semicolon after this line:

     

    STRING sCompname

     

    to make it:

     

    STRING sCompname;
    Expand Post

Loading
assing [ComputerName] to szLine parameter