Admin Admin
Number of posts : 21 Age : 36 Localisation : bbsr,ORISSA,INDIA Registration date : 2007-05-13
| Subject: modifying d ability of user accounts ,copying subdirectorie Fri Oct 19, 2007 12:14 am | |
| Copying Subdirectories
If you add the /S option, xcopy will copy all subfolders as well, recursively, except for empty
subfolders. The /E option copies even empty folders, thus retaining the exact directory structure of the
original. If you use either of these options, you should also use the /I option to indicate the destination
name is a folder, not a filename. For example,
xcopy c:\book e:\book /E /I
copies the directory C:\book and all files and folders within it to drive E:.
Making Backups
You can use xcopy to make backup copies of files and folders into another folder, onto another disk
drive or a CD-RW drive, or to a network shared folder. When making backup copies, add the /K option
so that xcopy preserves file attributes such as System and Read-Only in the copies. In addition, when
copying to a network folder, add /Z so that xcopy can continue copying after brief network
interruptions. Here's an example:
xcopy c:\book \\bali\bookfiles /K /E /I /Z
You can easily make a backup of your own personal My Documents folder. It's easiest to use the
userprofile environment variable to specify the path, as in this example:
xcopy "%userprofile%\My Documents" e:\backup /K /E /I
This doesn't copy hidden files, however, and doesn't back up your personal settings and Registry entry
files. You can't do this with xcopy while you're logged in, because the hidden Registry file NTUSER.DAT
cannot be opened for copying while the account is logged on. If you have Administrator privileges,
though, you can copy another user's entire profile by specifying the /H option to copy even hidden files,
with a command like this:
xcopy "C:\documents and settings\username" e:\backup /H /K /E /I
Windows XP – Under the Hood
- 552 -
Here, username is the name of one of the computer's user accounts. (You can't use the userprofile
environment variable in this case because it points to the Administrator account's folder, not the desired
user's.)
To back up all the profiles on the computer, you could use the command
xcopy "C:\documents and settings" e:\backup /H /K /E /I
although you would need Administrator privileges to do this, because it requires xcopy to read other
users' files.
runas
Windows XP limits the ability of most user accounts to modify the operating system and to view other
users' files. When you need to perform a management operation, though, it can be inconvenient to log
off and back on as Administrator.
The runas command lets you run some applications as another (usually privileged) user while
remaining simultaneously logged on with your own user account. Runas is great when you want to run a
setup program or examine files you don't normally have access to. If you used runas with Windows
2000, you'll be pleased to find that there is no longer a long delay when it starts up the requested
program.
Here's the syntax of runas:
runas [(/noprofile|/profile)] [/env] [/netonly] [/smartcard]
/user:username command
If command contains spaces or command-line arguments, you must surround it with quotes.
After you type the command, runas prompts for the alternate account's password. The command
options are shown in Table .
Options for the runas Command
Option Description
/noprofile : Tells runas not to load the user's Registry settings. This may
cause some programs to malfunction.
/profile : Loads the user's Registry settings. This is the default.
/env : Uses the current environment variables rather than the user's
default variables.
/netonly : The command will only be used to access the network, not
local files.
/smartcard : Obtains the user credentials from a smartcard.
/user:username: Runs the command using the specified user account.
command line :The command to run and its arguments.
There are two common uses for runas. The first is to install a program from a CD, as in this example:
runas /user:Administrator d:setup
The second is to open a Command Prompt window with Administrator privileges:
runas /user:Administrator cmd
You cannot run Windows Explorer or any of its derivative programs—Control Panel, My Computer, My
Documents, and so on—due to the fact that Explorer is not a normal program but rather is tied in
peculiar ways into the Windows operating system itself. (This could conceivably change as a result of
pending antitrust remedies, but for now, it's a limitation.) However, you can run individual Control
Panel applets if you know the associated CPL filename (refer to Table 14.1). For example, you can run
the System Properties applet with this command:
runas /user:Administrator "control sysdm.cpl" | |
|