469,917 Members | 1,474 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,917 developers. It's quick & easy.

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

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

@ECHO OFF
copy "C:\Program Files\Microsoft Visual Studio 8\VC#\CSharpProjects\date_string\date_string\bin\R elease\date_string.exe" c:\temp
set variable=c:\temp\date_string.exe
set AGCLOG="C:\RCP VIEWER PARSER\report.txt"
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_string.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
Aug 5 '08 #1
3 2934
Plater
7,872 Expert 4TB
this line:
Expand|Select|Wrap|Line Numbers
  1. set variable=c:\temp\date_string.exe 
  2.  
(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.
Aug 5 '08 #2
igurov
7
this line:
Expand|Select|Wrap|Line Numbers
  1. set variable=c:\temp\date_string.exe 
  2.  
(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 :
Expand|Select|Wrap|Line Numbers
  1. static int Main(string[] args)
  2.         {
  3.                 DateTime dt = DateTime.Now;
  4.                 string tostring = dt.ToString("yyyyMMdd");
  5.                 Console.WriteLine("{0}", tostring);
  6.                 return int.Parse(tostring);
  7.  
  8.         } 
  9.  
I need to assign the integer that is returned from the main function.
Aug 5 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Tim Pascoe | last post: by
10 posts views Thread by David Casey | last post: by
21 posts views Thread by Morten Aune Lyrstad | last post: by
4 posts views Thread by Bob T | last post: by
7 posts views Thread by C.Joseph Drayton | last post: by
15 posts views Thread by Lawrence Krubner | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.