none
Need help with easy script for open / close app and move files RRS feed

  • Question

  • Hi,
    I'm not a scripter.. never done anything special perhaps more complicated than /shutdown -s on cmd..
    I actually learned ASCII C language on university but never used it in real.

    I'm trying to create a basic script that perhaps you could help me or guide me how to do it..
    The commands are

    1) Close a running app (end task it or force kill it, I prefer end task it)
    2) delete files from x location
    3) run .exe app from y location
    4) close that running app 
    5) move files from z to y

    Perhaps adding few "wait few seconds" commands in between each, so the apps will launch successfully..

    My first question will be whats the easiest script language to do that?
    I tried VBScript but couldn't find commands for open or close apps.. also for controlling files..
    And what commands can do that? I could google them up for better understanding no need for rough guide
    And lastly, does it too hard? If it takes more than hour to make it (learn and process) than it ain't worth it..

    Thanks alot ahead!
    Jordan.
    Thursday, July 17, 2014 7:26 PM

Answers

  • 1) Close a running app (end task it or force kill it, I prefer end task it)
    2) delete files from x location
    3) run .exe app from y location
    4) close that running app 
    5) move files from z to y

    If you were to perform these actions from a Console screen then you would do this:

    1. Use taskkill.exe
    2. Use the "del" or the "erase" command.
    3. Use cd /d d:\Y, then "MyApp.exe".
    4. Use taskkill once more.
    5. Use the move command.

    Help is available for all of them by typing move /? (for example).

    After you get the commands to work, place then sequentially into a batch file (e.g. MyBatch.bat) like so, then invoke the batch file. That's all you need.

    @echo off
    taskkill . . .
    del . . .
    . . .

    Thursday, July 17, 2014 8:45 PM
  • I am not trying to put you off.  This forum and most forums are not set up to provide consulting services, write custom scripts or incrementally teach novices how to script. 

    We have far too many people coming here looking for free consulting and who wil spend hours and even days trying to beg a free scritp when they could write it in 5 minutes if they took the time to learn.

    The learning material on these sites is pretty extensive.  You can also get many good books on Windows and how to manage and automate simple tasks without scripting.  I recommend that if you don't want to take time to learn scripting technologies.

    Also if this is fro a business you might do better to hire a consultant as your questions show a general lack of technology background. The difference between ending an app and killing it is not much.  Al of the issues that come up point towards a need for a complete technical analysis and that there is likely a very simple way to solve your problem.  You may be trying to automate something that does not need to be automated.

    If you are just doing this for a home or personal system than consider this a chance to actually learn how a computer operating system works.  It may come in handy in the future.


    ¯\_(ツ)_/¯

    Thursday, July 17, 2014 11:38 PM

All replies

  • I recommend using either ASCII 'A' of 'B" as ASCII 'C" language is not useful on Windows. Apparently you college lied to you about language.

    I recommend starting with a language that you can understand.  How about looking here and see if one suits you fantasy: http://technet.microsoft.com/en-us/scriptcenter/dd793612.aspx

    We will not write this for you.  YOu are free to learn a language other than ASCII 'C' and post back with questions if you need help.

    By the way.  I think the only place that uses ASCII 'C" is the planet ASKALOTOFSILLYQUESTIONS.


    ¯\_(ツ)_/¯

    Thursday, July 17, 2014 7:44 PM
  • 1) Close a running app (end task it or force kill it, I prefer end task it)
    2) delete files from x location
    3) run .exe app from y location
    4) close that running app 
    5) move files from z to y

    If you were to perform these actions from a Console screen then you would do this:

    1. Use taskkill.exe
    2. Use the "del" or the "erase" command.
    3. Use cd /d d:\Y, then "MyApp.exe".
    4. Use taskkill once more.
    5. Use the move command.

    Help is available for all of them by typing move /? (for example).

    After you get the commands to work, place then sequentially into a batch file (e.g. MyBatch.bat) like so, then invoke the batch file. That's all you need.

    @echo off
    taskkill . . .
    del . . .
    . . .

    Thursday, July 17, 2014 8:45 PM
  • Don't waste your time on batch.  It is almost obsolete.

    I just figured out that you were trying to say you used "antsy" "C" in college.  If you know antsy C then you will really like PowerShell.


    ¯\_(ツ)_/¯

    Thursday, July 17, 2014 8:54 PM
  • Don't waste your time on batch.  It is almost obsolete.


    ¯\_(ツ)_/¯

    Almost obsolete it may be but it has two properties that speak in its favour for very simple tasks:
    a) It still works
    b) It requires no programming skills for basic tasks.

    Of course the OP has to become familiar with the individual commands themselves.

    Thursday, July 17, 2014 9:05 PM
  • Thank you all for your answers

    I didn't meant that I wanna program this script with C language.. I know that its stupid.. I just mentioned this to note that I have learned programming so I could handle some progressive answers including commands or programmer language/ words..
    and for Fredrik Long's algorithm Thank you for that, I'll try that on..
    and does this bat file is able to run on its own? like .vbs files? so I could make a schedule for that to run lets say every 2 weeks?

    Thanks !!


    • Edited by mcjordan92 Thursday, July 17, 2014 10:12 PM
    Thursday, July 17, 2014 9:49 PM
  • If you like 'C' you will like PowerShell.

    Yes you can schedule a batch file.


    ¯\_(ツ)_/¯

    Thursday, July 17, 2014 9:56 PM
  • hmm 2 questions:
    1) taskkill.exe causing me access deny error.. I used "taskkill.exe /IM softwarename.exe"
    how do I get permission or something to fix that?
    2) on the "move" command..
    First, its a "copy" instead.. but I easily figured that out.. 
    but more important is that I want to copy a folder.. with unknown list of way too long files and sub folders..
    and all I see is ability to move a file..
    Is this possible?

    Thanks
    Thursday, July 17, 2014 10:12 PM
  • This is why I pointed you to the learning materials and PowerShell.  You are asking for us to incrementally design this for you.

    You need to spend some effort to learn how to write a script.  The learning materials are there.  if you realy learned C then the learning will be very easy.

    This forum is not really set up to incrementally teach you how to write a batch file.  You know how to use help and how to read.  The rest is up to you.

    If you cannot figure out the simple answer to your questions then you are missing too many fundamental computer concepts.  Please sepnd some tim in the learning link.

    Fred almost completely wrote you whole script.  If you cannot understand that then you need to contact a consultant to help you sort this out.


    ¯\_(ツ)_/¯

    Thursday, July 17, 2014 10:33 PM
  • Totally understood..
    Didn't expect it to be way too hard..
    I'll spend some time learning it in the future.. meanwhile I'll let go from it..

    Just wanted to set a script that will automatically do what I manually needs to do every few days.. thought it wouldn't be too hard to create that.. Thanks alot for everything.. :)
    Thursday, July 17, 2014 11:23 PM
  • I am not trying to put you off.  This forum and most forums are not set up to provide consulting services, write custom scripts or incrementally teach novices how to script. 

    We have far too many people coming here looking for free consulting and who wil spend hours and even days trying to beg a free scritp when they could write it in 5 minutes if they took the time to learn.

    The learning material on these sites is pretty extensive.  You can also get many good books on Windows and how to manage and automate simple tasks without scripting.  I recommend that if you don't want to take time to learn scripting technologies.

    Also if this is fro a business you might do better to hire a consultant as your questions show a general lack of technology background. The difference between ending an app and killing it is not much.  Al of the issues that come up point towards a need for a complete technical analysis and that there is likely a very simple way to solve your problem.  You may be trying to automate something that does not need to be automated.

    If you are just doing this for a home or personal system than consider this a chance to actually learn how a computer operating system works.  It may come in handy in the future.


    ¯\_(ツ)_/¯

    Thursday, July 17, 2014 11:38 PM