By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
462,319 Members | 683 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 462,319 IT Pros & Developers. It's quick & easy.

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

P: 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
Share this Question
Share on Google+
3 Replies

Plater
Expert 5K+
P: 7,872
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

P: 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.