The Notebook Review forums were hosted by TechTarget, who shut down them down on January 31, 2022. This static read-only archive was pulled by NBR forum users between January 20 and January 31, 2022, in an effort to make sure that the valuable technical information that had been posted on the forums is preserved. For current discussions, many NBR forum users moved over to NotebookTalk.net after the shutdown.
Problems? See this thread at archive.org.

    Batch file programming

    Discussion in 'Windows OS and Software' started by orion95, Oct 11, 2007.

  1. orion95

    orion95 Notebook Consultant

    Reputations:
    11
    Messages:
    105
    Likes Received:
    0
    Trophy Points:
    30
    I was just going through a primer of batch file programming and wondered how could I do some trivial tasks by batch files like start media player after certain time intervals and things like that? Also does this have anything to do with Windows API?
     
  2. sasanac

    sasanac Notebook Evangelist

    Reputations:
    144
    Messages:
    456
    Likes Received:
    0
    Trophy Points:
    30
  3. Jalf

    Jalf Comrade Santa

    Reputations:
    2,883
    Messages:
    3,468
    Likes Received:
    0
    Trophy Points:
    105
    well, batch files are *basically* just a sequence of command-line commands. They can only do what you could do manually by writing on the command line.

    So unless you can find a command to schedule a program to start at specific intervals, you're probably out of luck. (Then again, I think Windows does have one or two commands for that, but can't remember what they are)

    And no, the Windows API is a set of C/C++ functions that you can call from within your application. Can't be used from the command line (so can't be used in bat files either)
     
  4. orion95

    orion95 Notebook Consultant

    Reputations:
    11
    Messages:
    105
    Likes Received:
    0
    Trophy Points:
    30
    Thanks for the help. But how can I perform filehandling operations using batch file programming, also is batch programming the best way to perform filehandling on your system?
     
  5. sasanac

    sasanac Notebook Evangelist

    Reputations:
    144
    Messages:
    456
    Likes Received:
    0
    Trophy Points:
    30
  6. Jalf

    Jalf Comrade Santa

    Reputations:
    2,883
    Messages:
    3,468
    Likes Received:
    0
    Trophy Points:
    105
    As I said, the same way as you would from the command line. Open cmd.exe and type in commands. Batch files are just a batch of those. (Hence the name)

    So file handling?
    you could do "copy a.txt b.txt" "del c.txt" or whatever. What do you need to do?
     
  7. orion95

    orion95 Notebook Consultant

    Reputations:
    11
    Messages:
    105
    Likes Received:
    0
    Trophy Points:
    30
    Operations like looking up an image file and loading it as a wallpaper from a folder at periodic intervals and keep changing wallpapers from that folder in given time intervals.
     
  8. Nir

    Nir Notebook Enthusiast

    Reputations:
    8
    Messages:
    41
    Likes Received:
    0
    Trophy Points:
    15
    even if you find a Timer command (for the intervals) you wouldn't want a normal batch-file for doing that cause it'll probably hog your system .. for not being true multi-tasking , I know there are plenty of freeware's to do what you ask .. im just too lazy to look 4it , try www.software.com or google.
     
  9. sasanac

    sasanac Notebook Evangelist

    Reputations:
    144
    Messages:
    456
    Likes Received:
    0
    Trophy Points:
    30
    If it were me doing something like that I'd do it a slightly different way and create a webpage which cycles through an array of images then enable "active desktop" and pick that webpage as the desktop.

    If you don't have any website authoring software I would think you can create a slideshow webpage pretty easily via Word (eek) or Frontpage (another eek!) or you may well find a template online. Try www.htmlgoodies.com the banners are annoying but the content is good!
     
  10. ScuderiaConchiglia

    ScuderiaConchiglia NBR Vaio Team Curmudgeon

    Reputations:
    2,674
    Messages:
    6,039
    Likes Received:
    0
    Trophy Points:
    205
    One other way for time specific batch files is to use the task scheduler to fire them off. This is MUCH better than using the batch file "AT" capability, because it does not require loading the batch file into memory at boot time and then having it hang around all the time waiting for the proper moment to do its thing. Task Schdeuler will handle the timing portion very nicely.

    Gary
     
  11. orion95

    orion95 Notebook Consultant

    Reputations:
    11
    Messages:
    105
    Likes Received:
    0
    Trophy Points:
    30
    I was thinking more along the lines of writing a standalone program, could that be done?
     
  12. jimc

    jimc Notebook Consultant

    Reputations:
    130
    Messages:
    269
    Likes Received:
    0
    Trophy Points:
    30
    it's perfectly fine to use the at command to schedule intervals IMO. at command uses the task scheduler
    there's no reliable way to change wallpaper though without a separate program.

    yeah, if you know a programming language
     
  13. orion95

    orion95 Notebook Consultant

    Reputations:
    11
    Messages:
    105
    Likes Received:
    0
    Trophy Points:
    30
    Which programming language would cater to the need here?
     
  14. iza

    iza Notebook Evangelist

    Reputations:
    449
    Messages:
    647
    Likes Received:
    0
    Trophy Points:
    30
    I'd suggest giving AutoHotkey a try. It's a relatively easy-to-learn scripting language, good for automating tasks and such, and is easily compiled into light-weight executables.
    Some things you mentioned like changing the wallpaper might be tricky, I'm not really sure how you'd go about doing that. You could probably ask in the autohotkey forums if/how it could be done.
     
  15. swarmer

    swarmer beep beep

    Reputations:
    2,071
    Messages:
    5,234
    Likes Received:
    0
    Trophy Points:
    205
    Do you know any programming languages?
    You could look at tcl or python as alternatives to batch files.
     
  16. AKAJohnDoe

    AKAJohnDoe Mime with Tourette's

    Reputations:
    1,163
    Messages:
    3,017
    Likes Received:
    0
    Trophy Points:
    105
    I still have an old DOS version of Quercus REXX that still ran under XP (haven't tried it under Vista) that was a nice way to do quick little procedural programming with a non-compiled interpretive language.
     
  17. chimpanzee

    chimpanzee Notebook Virtuoso

    Reputations:
    683
    Messages:
    2,561
    Likes Received:
    0
    Trophy Points:
    55
    There is a Windows power shell which is AFAIK CMD on steroid.

    Though I would prefer python which is easy to learn and with very good windows support.
     
  18. orion95

    orion95 Notebook Consultant

    Reputations:
    11
    Messages:
    105
    Likes Received:
    0
    Trophy Points:
    30
    Okay python sounds reasonable, what about vc++?
     
  19. swarmer

    swarmer beep beep

    Reputations:
    2,071
    Messages:
    5,234
    Likes Received:
    0
    Trophy Points:
    205
    C++ is a lower-level language than the others we've been discussing. It depends on the task... but for most system-scripting type tasks, using C++ would involve more work and make it trickier to debug.

    I'm still a bit vague about what you want this program to do though....
     
  20. AKAJohnDoe

    AKAJohnDoe Mime with Tourette's

    Reputations:
    1,163
    Messages:
    3,017
    Likes Received:
    0
    Trophy Points:
    105
    You might even be able to use Vista's Task Scheduler for some of the tasks mentioned in the initial post.
     
  21. orion95

    orion95 Notebook Consultant

    Reputations:
    11
    Messages:
    105
    Likes Received:
    0
    Trophy Points:
    30
    I am asking about visual c++ from MS, I wanted to write a program that could tweak system appearance on its own from time to time.
     
  22. AKAJohnDoe

    AKAJohnDoe Mime with Tourette's

    Reputations:
    1,163
    Messages:
    3,017
    Likes Received:
    0
    Trophy Points:
    105
    Well, have fun then!
     
  23. Jalf

    Jalf Comrade Santa

    Reputations:
    2,883
    Messages:
    3,468
    Likes Received:
    0
    Trophy Points:
    105
    I'd stay away from C++ (and VC++ is just Microsoft's tool for developing C++). It is a pain to learn, even worse to master, and for what you want to do, I can't think of a less suitable language. ;)

    You could try out C# or Visual Basic.Net instead. Both of these are very well integrated into Windows (which means it should be simple to do the tasks you want), and both are much easier and simpler languages to work with.

    And of course, Microsoft has free software available for developing in both.
     
  24. ScuderiaConchiglia

    ScuderiaConchiglia NBR Vaio Team Curmudgeon

    Reputations:
    2,674
    Messages:
    6,039
    Likes Received:
    0
    Trophy Points:
    205

    Can I get an AMEN brothers and sisters?

    Yes stay away from C++, it's powerful but very cryptic. c# or VB.net are much better choices and the express editions as Jalf said are free.

    Gary