Simple example of batch file and windows scheduler - command-line

I need to create a batch file which will copy web log files from a web server to a local desktop box on daily frequency.
I'm a web developer, but I'd like to take a stab at learning the process for creating a batch file and I think using the windows scheduler should get me where I need to go.
In any case, I'm just looking for a jumping off point.
I understand the premise behind a batch file (echo to print info, commands to cause actions such as mkdir or move, etc), but some straight forward tutorials would be great.
Or even a reference guide such as devguru.com or 4guysfromrolla.com would be helpful.
Thanks,

Creating a batch file is relatively straightforward.
Just type out the commands you want as you would in the command shell, and save the file with a .bat extension.
There's a simple example here that you may find useful. Note, you can use any editor to create your batch file, as long as it saves in a text format.
Depending on which version of Windows you're using, the process to create a scheduled task is slightly different:
Windows XP
Windows Vista
Edit: A little followup on misteraiden's answer.
Essentially, what you're looking for is scripting functionality. There are a variety of tools available. A batch file is the simplest form of scripting that Windows supports. You could, for example, write scripts in PowerShell or Python. Both are more powerful and flexible scripting languages. Depending on what the requirements are for your script, and what you feel like learning, they may be more appropriate.
However, If all you want to do is a copy, the simplest, easiest place to start is a batch file.

This is a little left-of-field, but using an XML build interpreter such as NAnt could come in handy here. Probably over-kill for what you are trying to do, but if you learn it now, you'll be able to apply it's uses in many different places.
You could use Windows Scheduler to trigger the build, which would then complete various operations such as deleting, copying, logging on to network shares.
However, perhaps to learn this you would probably need to learn more about the command line and command line programming.
Either way, I recommend you check out some of the NAnt examples that deal with copying and other basics etc..

I found one of the best references other than the Microsoft website that was mentioned in an earlier is: http://www.robvanderwoude.com/batchfiles.php I have been using this for many of the issues I have had and have been using it to learn more. I think since you have the premise of how batch files work, this will work out will for you.

Related

Find scripts that call a script in FileMaker

Is there a way in FileMaker, either by using the application features or by writing scripts, to find what scripts call a specific script?
This strikes me as an essential ability when debugging, and ironically my text editor does the same task as a matter of course when I hit ctrl-f.
The only way I have been able to find to do this is to print the entire set of scripts out to a PDF and then search that. Surely there is a better way.
The tool FMPerception can do that and more, but it is a paid tool and I find it rather expensive as most other FM helper tools. There is also 2empowerFM Plug-in Family: www.2empowerFM.com that you can use to search and find in all your scripts, this is also a paid tool but not as expensive as others and this one can for sure help a lot in your daily developing of FileMaker.
Disclosure: I don't work for either one of those companies.

Batch file to compress all folders/files and send through mail

I need to create a batch file that will compress and zip all the files and folders in folder.
Once the the files and folders are zipped, the .zip file should be sent by email.
I am using Windows 7.
I dont have any idea about batch scripting. Please help.
Thanks in advance
The answer would depend on which operating system the script will run on, but you didn't even provide that.
You don't say if you are knowledgeable about any languages like C# or Java or Python, but I'd recommend writing the app in something like that. There are lots of libraries to help you with zipping, threading, etc. You might find it easier if you open up your restriction on languages.
But, if you must, here's a solution that might help you:
https://superuser.com/questions/110991/can-you-zip-a-file-from-the-command-prompt-using-only-windows-built-in-capabili
You can use 7zip for the zip functionality. Using its command line options you can create a batch file.
With regards to emails, if you really have to do it in batch then you will need a 3rd party tool, or a command line tool.
A quick google revealed this site which even has batch examples.

Using a build system for reproducible research?

I am doing a research project that involves a pipeline of programs, each generating an output file that becomes the input for the next program. I would like to make it easy to repeat the series of commands that I used to create the desired output. It seems like make or any other build system would be a good fit for this task, but all the build systems that I've looked at (except for maybe make itself) seem to be strongly biased toward building executabe files from source code, and I can't figure out how to do anything else with them. Does anyone have experience using a build system for tasks other than compiling source code into executables? Can I easily use a build system to facilitate reproducible research, or should I be looking for a different kind of tool?
Well, I figured this out by myself eventually. I'm using plain old (GNU) Makefiles.

write/append in my own exe with c programming

How can I append my own exe to upgrade it with c programming. I have tried to use append mode in exe but helpless with it. Any way to modify any exe? There are simpler process for .txt but none for .exe.
I want to add the codes or join the functions just like any program updates.
It's not that simple. You can't (simply) add code to the end of an .exe file to modify it; there are internal indexes, tables, etc.
For software update you need to replace the file in question with a newer versions. There are frameworks for doing that in an easy and automated way. If you tell is what language and environment you are using, someone is sure to recommend a good software update solution.

PowerShell - Distributed Solution

I'm new to PS so I may get some of the terminology wrong.
If you want to roll out a custom PowerShell environment (snap-in) for a team of 30 developers/DBAs. What is the best way to do this... if you intend to be rolling out new functionality once a week? Does PowerShell 2.0 help in this regards?
Assumption:
There is no issue with everyone on the team installing PowerShell (v1 or v2)
Update:
Also see Jeffrey Snover's answer about v2 below.
It will depend to a certain extent on the sort of functionality changes that you intend to do. For our environment, we roll out a pretty standard PS install then add one line to everyone's profile to run a script from a shared folder on a server. Then in that script I can do whatever customization that I want to have applied to everyone.
We add the line to the machine specific MS profile (the one in %Windir%) this was an intentional choice. We do it that way so that the users essentially only get this on their production boxes. That way when they write something they can quickly log into a test box and run the script to make sure that the script will deploy without nay dependencies on these customizations.
Currently the customizations are pretty mundane. Mostly just some added functions and aliases. I also have a logger that I wrote in C# specifically for powershell so it loads that up from the dll that is in that same network folder.
Because I play around with my environment so much, I have this in my profile :)
$ProfileDir = ([System.IO.Directory]::GetParent($profile)).FullName
$localMSProfile = "$PShome\Microsoft.Powershell_profile.ps1"
$localAllProfile = "$PShome\profile.ps1"
$userAllProfile = "$ProfileDir\profile.ps1"
$userMSProfile = "$ProfileDir\Microsoft.Powershell_profile.ps1"
$allProfiles = ($localAllProfile, $localMSProfile, $userAllProfile, $userMSProfile)
This is why we added MODULE support in PowerShell V2 - it is the easiest mechanism to xcopy deploy sets of functions. The Module documentation is pretty light at this point but should be much better in a month or two.
Experiment! Enjoy! Engage!
Jeffrey Snover [MSFT]
Windows Management Partner Architect
If you are rolling out a new version of the snap-in weekly, switching version probably won't help with that part of things. However, you'll be developing on a newer platform, with the advantage of the extended functionality that comes with it.
As already suggested some scripts could ease the deployment pain to the point where you have to do nothing but maintain those scripts correctly and keep producing new builds.