Using vssadmin through a batch command or powershell - windows

I need to access a file that is open by another process all the time. The best way would be for me to use Windows Shadow Copy to create another copy of the file and then use the copied file.
Does anyone know how to use vssadmin to create a backup and extract a specific file through a batch command or power shell? I would like to automate the process to run every night.
Jason

Here is a page with examples on how to create snapshots from a command line with vssadmin:
http://blogs.msdn.com/b/adioltean/archive/2004/12/14/301868.aspx

Related

Batch file to rar and password (very specific)

I was trying to make a batch file that compresses a specific folder (using winrar) to a specific location (not the same as the folder location), password (that I can choose myself) protects it AND does all of that without a cmd screen popping up.
I have very little knowledge of programming and managed to get some things working, but not all at the same time and in the same batch file.
Also to rar that file do I need Winrar to be installed on the computer or can I reffer to the rar.exe (copied from the Program Files Windows folder to a different location)?
AFAIK it's not possible to run a a bat file without a visible CMD window without using any additional tools. Here's a link to a post how to run a hidden console: https://superuser.com/questions/62525/run-a-batch-file-in-a-completely-hidden-way
It is possible to use just the rar.exe but I would use 7zip instead. The performance is way better, it's also portable and you have many options in the command line. So your project would contain the bat file itself, the vb script file and the 7z.exe (or rar.exe). If you want, you can even create a single .exe file out of these three by creating a SFX file: http://www.7zsfx.info/en/
Hope I could help you.

How to create and execute a file full of commands on Windows command prompt?

Example:
In Linux we can put the desired commands in a file and give it executable permissions. This helps us to actually run the file on the terminal and thus all the commands inside the file get automatically executed.
How to achieve this on Windows XP?
Same thing, but it's called a batch file, extension is .bat. You can also double-click to run these. This site is a great resource.

How to copy the file from one windows machine to another windows machine in a particular drive using batch script?

In my windows server, am taking SQL DB backup in C drive. I wants to copy this .bak file to some other client windows machine in a particular drive with the current date using batch script. So that i can schedule this batch script using scheduled task. please help me out.
Can anyone, give a script to run this. thanks
Batch files are always tricky to get just right. First I'd open a command line and see if you can copy between two machines using the following syntax:
copy C:\localfile.bak \\remotemachine\c$\Path\remotefile.bak
(where "remotemachine" is the name of the remote machine and "c$" is the drive you wish to copy to). You can then copy this into a batch file and set up a scheduled task.
As for renaming the file to have the current date and time, I suggest you start with this question as it may involve some effort to get it into a format you want.

Windows .bat file doesn't execute its sequence

I created a simple install.bat file into my application folder, to execute its thing on windows.
But it only executes the first line of the .bat file.
Is there something that I need to add so it continues after the first one is done?
copy something somewhere
move something somewhereelse
gem install etc
Above are the type of commands that are in the .bat.
Do I need to anything something inbetween?
Is the first command in your batch file actually a copy command, or is it a command that's running another batch file?
Running a batch file from another by simply using the second batch file;s name will not return to the calling batch file.
If you want one batch file to invoke another and return you have to use the call command.
Are you overwriting a file? If so you'll need to add the /Y to the copy command to supress the prompt that asks if you want to overwrite the file.
Use the /h parameter to get help on the copy command. It will show this usage and some others.
As written above, all three lines will execute. I imagine that the second and third lines are failing. You should capture the output which will explain why those lines failed.

Scheduled Task: Directory cleanup using windows batch script

I have a shared disk that I would like to clean up once per week using a scheduled task of some sort. I would like to use a batch script so that the system admins can easily modify it or reuse it on other directories when needed.
The directory has files with multiple file extensions but the ones that need to be deleted end in .bkf and must be over 2 weeks old.
Does anyone have a batch script solution for this windows server (not sure which version)?
If you have PowerShell (or can install it), check out this link: http://thepowershellguy.com/blogs/posh/archive/2007/12/13/hey-powershell-guy-how-can-i-delete-files-that-are-a-specified-number-of-hours-old.aspx
Take a look at this page - scheduling tasks from command line
It shows you hot to create scheduled tasks from the command line. You might be able to use this in combination with other dos commands to get your result.
The only thing that needs to be in the batch file is
#echo off
cls
del C:\some\directory\*.bkf
And the delete path can also be sent to this batch script as an argument so that the directory is changeable.
I ended up just writing an EXE that accepts parameters and scheduling that. Unfortunately the other solutions didn't have the flexibility needed.
have you looked into forfiles.exe?
http://blog.stevienova.com/2007/02/27/forfiles-delete-files-older-than-x-amount-of-days/

Resources