473,466 Members | 1,443 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

run time.bat through C programming

13 New Member
i want to run time.bat through C programming i used system command in this way :-
Expand|Select|Wrap|Line Numbers
  1. *-----------------**---------------------------------
  2. //(time.bat file)
  3. @echo on
  4. time
  5. @echo off
  6. **---------------------**------------------------------
the problem is the program is running correctly with no error in compiling but showing only clear output screen and ma time.bat batch is not running what shall i do to run that file in c ?? please help me:'(

Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. #include<process.h>
  3. #include<stdio.h>
  4.  
  5. void main(){
  6.  print("calling time.bat\n");
  7.  system("E:\TURBO\BIN\time.bat");
  8. }
Mar 24 '13 #1

✓ answered by weaknessforcats

I suspect yur progaram is running so fast all you see is a black screen for a split second.

Insert a getchar() after your system call. That will halt the program until you press enter. This will give you time to read what's on the screen.

7 1502
weaknessforcats
9,208 Recognized Expert Moderator Expert
Have you tried:

Expand|Select|Wrap|Line Numbers
  1. system("E:\\TURBO\\BIN\\time.bat");
  2.  
The \ is a preprocessor escape sequence. The character following the \ is a code. So you need a \\ to force the \ you need in your path.
Mar 24 '13 #2
anugrahbala10
13 New Member
Sir i did the way u said bt stil i have same problem:-(
Mar 24 '13 #3
weaknessforcats
9,208 Recognized Expert Moderator Expert
I suspect yur progaram is running so fast all you see is a black screen for a split second.

Insert a getchar() after your system call. That will halt the program until you press enter. This will give you time to read what's on the screen.
Mar 24 '13 #4
anugrahbala10
13 New Member
Thank you so much sir it works..sir i called two .bat files together how can i make the time diffrence between both the call?
Mar 24 '13 #5
weaknessforcats
9,208 Recognized Expert Moderator Expert
Exactly what are trying to measure? How long your .bat file takes? Or something else?
Mar 24 '13 #6
anugrahbala10
13 New Member
i just want to make a time delay in opening between two ".bat" files by code for eg
open "time.bat" nd after 5 sec open "sys.bat"?
Mar 24 '13 #7
weaknessforcats
9,208 Recognized Expert Moderator Expert
There is a sleep function that will pause your program for a nuber of seconds:

Expand|Select|Wrap|Line Numbers
  1. sleep(5);  /*wait 5 seconds */
It is not a ANSI standard function so you may not hve access to it. If not, you can write your own sleep function:

1)Pass in the number of seconds to wait
2)clock the system clock. This is your start time
3)start a do loop
4)inside the loop clock the system clock. This is your current time.
5) stay in the loop as longs as start time+wait seconds is less then the current time.
6) return when you drop out of the loop.
Mar 24 '13 #8

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

Similar topics

18
by: Ken | last post by:
Hi. Can anyone refer me to any articles about the compatibility between c++ polymorphism and real-time programming? I'm currently on a real-time c++ project, and we're having a discussion...
2
by: PX | last post by:
Greetings, For those who want to be/already are quants or software engineers in financial firms, does any of you happen to know some resources about C++ real time programming for trading system?...
28
by: marcpirat | last post by:
hi we create a real-time program on a embedded linux system. the program will run a few time by second i would like to know if it's better to create global variable or create the variable in...
2
by: Angus | last post by:
There are the C runtime library functions of course, but are there any STL time or date related functions? I couldn't find any.
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.