.cmd script - setting a variable equal to a result from .exe C# programm

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • igurov
    New Member
    • Jun 2008
    • 7

    .cmd script - setting a variable equal to a result from .exe C# programm

    Hi all,
    I have the following simple cmd. script:

    @ECHO OFF
    copy "C:\Program Files\Microsoft Visual Studio 8\VC#\CSharpPro jects\date_stri ng\date_string\ bin\Release\dat e_string.exe" c:\temp
    set variable=c:\tem p\date_string.e xe
    set AGCLOG="C:\RCP VIEWER PARSER\report.t xt"
    echo Setting the variable...
    echo --- start ----- >> %AGCLOG%
    echo %variable% >> %AGCLOG%
    echo --- end -----
    pause

    The date_string.exe programm converts the current date to a string and return it. But when I assign the return value to the variable "variable" it doesn't work. The output in the report.txt is the following:

    --- start -------
    c:\temp\date_st ring.exe

    i.e the result of date_string.exe is not passed to the variable.
    Any ideas how can I assign the return value of the function to the variable.

    Thanks in advance.
    Iliya
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    this line:
    Code:
    set variable=c:\temp\date_string.exe
    (If anything) will attempt to assign a variable called "variable" to the return value of the main() function in date_string.exe . Which unless you changed it, would be a 0.
    If you want the stdout from the program you need to use redirect I think.

    Comment

    • igurov
      New Member
      • Jun 2008
      • 7

      #3
      Originally posted by Plater
      this line:
      Code:
      set variable=c:\temp\date_string.exe
      (If anything) will attempt to assign a variable called "variable" to the return value of the main() function in date_string.exe . Which unless you changed it, would be a 0.
      If you want the stdout from the program you need to use redirect I think.
      And how exaclty can I use redirect. Can u give me an example. The main function is only :
      Code:
      static int Main(string[] args)
              {
                      DateTime dt = DateTime.Now;
                      string tostring = dt.ToString("yyyyMMdd");
                      Console.WriteLine("{0}", tostring);
                      return int.Parse(tostring);
      
              }
      I need to assign the integer that is returned from the main function.

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        What you need, is to go look through some basic tutorials.




        Comment

        Working...