executing copy command in a batch file - windows

I'm using a windows copy command to perform auto file backup of Microsoft outlook files for a domain users.
the problem exists after 6 month of using this batch file is that the .pst file size for each user is growing and the copy operation is getting too long to complete.
i want to know are there any way to copy only the changed bits in the .pst file couse what i'm doing is copying the whole file each time a user login.
copy C:\"Documents and Settings"\%USERNAME%\"Local Settings"\"Application Data"\Microsoft\Outlook\ \\storage\folder1\folder2\%USERNAME%\%DESTDIR% /y /v
thanks

This page might help you in doing that : link

In a word: with the regular Windows copy command, no.
You've a few alternatives, though. Probably the best is to ask your users (or get your administrator) to reduce the size of the mailbox.
Another is to try the robocopy utility, which is part of the Windows Server Resource Kit and which replaces xcopy in versions of Windows above Server 2008 R2. In my experience this is a little faster. It also includes an option to skip the copy if the file hasn't changed, which may help if your users only use email infrequently.
rsync (details here, Windows version here) does a true differential copy, so only the changed bytes between the files are copied. However this needs to be installed as a Windows service on the listening side and needs to be installed as a program on each client.

Related

What is backup mode in Robocopy

I am trying to copy a large database backup file over network.
The .net FileInfo.CopyTo or xcopy failed with different binary resulted. Also tried robocopy without parameter, and resulted a failure. Just did another attempt with robocopy using /zb parameter (restart and backup mode). It took much longer but resulted in a success.
My question is, is backup mode in robocopy really designed to copy large / backup file? Have searched through net and couldn't find a clear answer.
Would appreciate if any experienced user could give me a hint or better solution on large file copy over network. Thanks.
Just want to share an update on resolving the issue above.
In my case, xcopy failed to copy the file over 10GB across servers in different domain and server location.
On the other side, robocopy with
/zb - Uses Restart mode. If access is denied, this option uses Backup mode.
can successfully copy. It increased the time from 1hour to 2.5hours though.
--
After re-arranging server, the file is copied across servers in the same domain and server location now. And using xcopy is alright too.
--
So my theory on this would be probably about the stability connection between servers. If the connection is not robust (with occasionally drop out causing an access issue), when copying large file like my case, a corruption likely occurs any time during the long process; robocopy with restart and backup can recover the copy pretty well. Time spent on recovery is probably the down side.
And as a side note, FTP instead of copy should be used if it's going to be a routine task.
Backup mode only allows Robocopy to back up and restore all files, regardless of their own individual permissions (NTFS ACLs) on those files.

How to copy files on a CMD on LAN (windows xp)

hello I don't know about this but I found this on Internet cafe but I don't have enough knowledge on how .bat files works, So I want to know how to copy files like this display.
And the files is already shared so that I can copy. All PC don't have password. Just directly log-in to desktop.
Input location to copy: \\PC1\Steam\Steam\SteamApps\common\dota 2 beta
Input location to paste: D:\Games\Steam\SteamApps\common\dota 2 beta
then it will alert me if done. The files will be overwrite and paste all data.
I don't know the code of copying too and I search too many still cant understand. I just want to use this on my internet cafe so that I don't update games anymore on every PC. Because copying on directly network is my costumer don't know.
Copy -y "source" "destination".
With the quotes if there are spaces in the path. Also, if copy does not want to copy from the network unc, then first connect to the unc using "net use".

Visual Basic 6. Global/Public Folder Location That Limited User Can Write Data

I am a vb6 coder, and facing problem with a Windows 7 UAC issue.
Limited User:
When I run my installer, it asks for an admin account password, I enter and it installed it correctly.
My app writes dates to a common application data folder so that all users can access the file/data.
In Windows 7, the path is :
C:\ProgramData\<CompanyName>\<AppName/Title>\Config.ini
as my installer runs with admin rights, it creates those subfolders correctly.
But, when the app runs from a limited user account. It failed to write at that location (it actually writes to virtual path).
But, I want to write to that exact file.
However, I have researched enough and every where it is told to write in CommonAppData folder.
But it still fails.
please some one help me out.
I use SHGetSpecialFolderLocation API call to get the folder location and I use folder id 35.
below is the sample code for the path:
strAPPPath = fGetSpecialfolder(35) & "\" & App.CompanyName & "\" & Trim(App.Title)
I wasn't trying to suggest that your installer was the problem, I wanted to know what capabilities that your installer had. As I said I am running a post install Custom Action, in it I make my directory, set the permissions on it and copy my config files to it. It looks like your Installer has the ability to do Interactive and Shell Operations, but since I am not familiar with it I will refrain trying to give you an example. The command that I use to set the permissions of the Directory is the dos calcs command. And the command line that I use is.
cacls "%ALLUSERSPROFILE%\**<Your Directorys here>**" /E /P BUILTIN\Users:F
I was hoping someone would jump in and give an alternative way to do this, since I would like to loose the bat file.
You could try using procmon from www.sysinternals.com (which redirects to MS Technet) and find the disk access that your application is making to access the data folder.
It will give you a better error message that should point you in the right direction, such as permissions.

Automatically update Windows fully

I'm working on a project where the goal is to be able to update a windows computer 100%. That means a program or a script that updates windows automatically with no user interaction at all. Ideally a standalone script that can be run from another script.
The reason: I need to update a lot of computers in my line of work. They can be at any patch level and everything from Windows XP to Windows 8. My goal is to start a script, wait/do something else and then find a fully patched computer.
I've solved a lot by finding ZTIWindowsUpdate.wsf in the MDT Task Sequence.
This can be used like this from an admin cmd:
cssript.exe ZTIWindowsUpdate.wsf
My problem so far is that the computer requires a reboot between some of the updates. Probably because of dependencies. ZTIWindowsUpdate.wsf needs to be run as administrator and i can't seem to find a solution to start it as administrator at reboot. Additionally if I get the script to run on startup, how do I stop it, and how do I know when its time to stop it?
Can someone help med with a foolproof solution to this problem?
Thanks!
Don't need to FULL update a Windows OS, most of the updates are not needed, most updates are not relationated with security and we can survive without they, you need to read the description of each update to understand what changes made. FULLY updating a Windows can be negative point of performance in several scenarios.
All that you need is to download your desired updates, then store it in a folder with this batch script:
#Echo off
For %%# in (*.msu) Do (
Echo: Installing update: %%#
Wusa "%%#" /quiet /norestart
)
Echo Windows Update finished.
Pause&Exit
Also you can compress the folder (the updates + the script) into a Self executable with winrar to distribute it as a standalone file.
Info:
Wusa.exe is the Windows Update commandline application.
The files are processed one by one, not all at once.
The quiet switch makes the installation silent.
The norestart switch don't restart after installing the update even if needed.
If a update is installed in the OS then is not installed again, without getting an error window or stopping the execution of the script.
PS: See Wusa /? for more switches.
I hope this helps.
UPDATE:
Another alternative is to download and install ALL the updates with WSUS utility.
http://download.wsusoffline.net/
The updates for Win7 x64 (for example) are stored here: "...\wsusoffline\client\w61-x64\glb"
PS: The "DoUpdate.cmd" batch file in the "CMD" dir of the application is what you need if need to automate the task in "background".
The simplest solution to the problem you're describing is to get your script to configure automatic logon for the built-in Administrator account, then add itself to the Startup folder. You do need to know (or reset) the Administrator account password to use this option.
There are many other possibilities, some examples are: use a startup script and psexec; use srvany to create a service that runs your script; use task scheduler to schedule your script to run automatically, either interactively or non-interactively; disable WUA, configure automatic logon for the account you're using, and add your script to the Startup folder.
Note that you'll save time and bandwidth if you can set up a WSUS server or (even simpler, and cheaper if you don't already have a Windows server) a transparent caching proxy. However this won't avoid the need to reboot during the update sequence.
You may find my script useful as an alternative starting point to ZTIWindowsUpdate.wsf, if only because it is smaller and simpler to understand.
The moast time consuming thing of a WindowsUpadate procedere is the download of the Setupfiles for the Updates. You should look into a lokaly in the network installed WUS (Window Update Server) and make sure the PC updates from the WUS. If the PCs are all in a ActiveDirectory Domain then the needed settings are very easy to manage. But if not this setting could make a simple batch-script which uses the normal windows update routine.
Another solution would be to make batch-scripts where you install the predownloaded updateFiles with the silent-switch. Allmoast every setup.exe has such a silent switch. If a update isn't needed the update stops for this upload automatically. I'm using such a batch-script wizzardy now for quiet a time now.
PS: If the Computer were from one/your compagny you should "thank" your predecessor for many hours of work to the far future.
PPS: By the way XP and Vista should be phased out. They are now realy old and for XP the already extended supporttime is axed by Microsoft next year and should only used if it is realy realy needed for one small situation where a Windows 7 isn't a solution in any way possible.
To run
cssript.exe ZTIWindowsUpdate.wsf
as Administrator after reboots, you can create a Task in the Task Scheduler with the proper permissions and to run on boot. =]
An automated way is, WuInstall. I'm using it for 1 year now and it's perfect, it actually does what it should. It's a command line tool which automatically searches, downloads and installs the updates. There are several "switches" that let you allow to customize the process. Thanks to the rebootcycle-switch for instance, updating a newly setup PC is done with ease - in one go.
Here's another way ------
Perform instructions below at your own risk:
To automate windows update these instructions may or may not work for your system however it appears to work to an extent for Windows 7 as these instructions were tested on Windows 7.
MUST READ: 1. If the step below does not work verify then you are most likely part of a domain and your security policy may not allow you to perform steps below! 2. UAC prompts were also disabled for the duration of the windows updates so the batch files can run without interruption; be careful to restore this to default when done
Caution this step will make your computer less secure, immediately remove this after your computer is completely up to date. Set a reminder for 24 hours later if need be:
1.
First you will have to make sure your computer automatically logs into a user. You can do this by clicking start menu, type "netplwiz", press enter or open the wizard, under the users tab, select your username, and un-check "require password", type your password, close this window.
2.
Create 3 batch files to start the automated process. (Open notepad paste each code into a separate notepad and perform a save as corresponding_file_name.bat)
One. Save as: any_name.bat then copy this batch file to your startup folder for the user you made auto login. (Click start > All Programs > Startup)
start "" c:\autoupdate1.bat
exit
Two. Save as: autoupdate1.bat then copy this to C:\ drive
wuauclt /detectnow
wuauclt /updatenow
reg query "HKLM\Software\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired" > nul && shutdown -r -t 0
start "" c:\autoupdate2.bat
exit
Three. Save as: autoupdate2.bat then copy this to C:\ drive
ping 127.0.0.1 -n 61 > nul
start "" c:\autoupdate1.bat
exit
Restart or open the batch file in the startup folder and watch the magic begin!
3.
When it is completely done updating just delete the batch files from the startup folder & c:\ drive
Once again follow these instructions at your own risk as it can create an endless loop if you do not know how to stop this process by removing it from the startup folder or going into windows under safe-mode to remove the batch files
Final notes: If you run into issues running the batch files chances are you may have to look up how to disable UAC prompts for your Windows version

Are there any FTP programs which can automatically send the contents of a folder to a remote server?

Are there any FTP programs which can automatically copy (or rather 'move') the contents of a folder to a remote server? I have of course googled this but only really found one or two ancient products which look really clunky and unmaintained. I was wondering if there's a way to do this from the command line or any better solution to the base problem.
In more detail, new files get written to a folder every few hours. These new files need to be FTP'd elsewhere and then deleted. Mirroring or synchonisation systems are probably out of the picture as we need to delete the source files once they've been successfully transferred.
If it's easier, the 'solution' could pull the files off the server (rather than the server pushing them to the client). The computers will both be Windows OS.
You could use any off the shelf FTP program that supports command line and schedule a task on Windows Scheduler to run every 10 minutes. Check the folder, and move any files to the FTP site.
In the end I used a program called FTP Auto Sync: http://ftp-auto-sync.com/

Resources