Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

Best language for file manipulation and simple windows tasks


  • Please log in to reply

#1
ryurek

ryurek

    Member

  • Member
  • PipPip
  • 12 posts
I have a little programming experience in C++ and VB. I've played a bit with python recently, but find the lack of a single file executable annoying. What I need to do is basic file manipulation. What I'd like to do is basic windows interaction stuff. I need to copy files, delete old files, move files, etc etc. Pretty simple stuff but involving variables such as whether the files exist, which user is logged on, etc. Ultimately I want to do windows interaction stuff to reboot if the user needs to, launch multiple applications depending on what the user wants, verify appropriate user is logged on before performing tasks etc etc. I assume VB would be the way to go, but don't want to get outdated nor do I want to take 4 years of school just to perform simple tasks. Any ideas which language would be best for someone like me? I'd hate to buy VB just to be told in a year that MS won't support it anymore or find that I can't do everything I want with it. Should I just forget the windows interaction and use C++ for file manipulation or should I forget what I've learned so far and go with JAVA? I'm not looking to make complete programs or games, I just want to automate some basic tasks.
  • 0

Advertisements


#2
Swandog46

Swandog46

    Malware Expert

  • Member
  • PipPipPipPip
  • 1,026 posts
  • MVP
Depending on what you want to do, I just use batch scripting for this, or Python or C if the task requires it. So I think you have chosen the right languages.

Batches are ideal for these sorts of tasks in general because they behave as direct system() calls in C. So you can just write commands as though you were typing them into the cmd.exe interface. If you wanted to write a batch that took two arguments and copied the second file to the first file you could do:

copy %2 %1

You have the "if exist" command like you mentioned too.

if exist %1 echo File %1 exists already!
if not exist %1 copy %2 %1

Shell scripting is useful for these sorts of simple tasks. For more complicated tasks (parsing files, string processing, regular expressions, whatever), you'll need to use a scripting language like Python (my personal favorite).

Hope this helps :whistling:
  • 0

#3
ryurek

ryurek

    Member

  • Topic Starter
  • Member
  • PipPip
  • 12 posts
I have actually been getting into batch files a lot more lately but I find the limitations annoying...sending things to a text file then pulling them out instead of just holding a place in memory is annoying...I guess if I get into it a bit more the syntax will come second nature and it'll be easier... But I'm not sure I can do the things I want to with it... for instance virus or spyware removal, if there's a program that needs to be pulled out of the current users doc's and settings folder, I'd just be clueless how to do that in batch...although removing files sure would be a lot easier.....
  • 0

#4
Swandog46

Swandog46

    Malware Expert

  • Member
  • PipPipPipPip
  • 1,026 posts
  • MVP

sending things to a text file then pulling them out instead of just holding a place in memory is annoying

Yes, believe me I understand that...

It really depends on what you want to do. If you are deleting or copying files batch scripting is ideally optimized for that sort of task. (By the way you can grab the location of the current user's Documents and Settings folder using the environmental variable %homepath%. Check out the environmental variables by typing set at a command prompt --- there is more to them than you might think!)

But yes, for more complicated tasks you will for sure have to graduate to another language.
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP