Jump to content

Recommended Posts

Posted

Hi,

Can someone tell me the commands to do the following in a CMD or batch:

I want to do the following with a cmd:

regsvr32 /s %SystemRoot%\system32\File.dll

And i also want to know how to move a file:

I have a file at the local disc, (C:/) and i want it be moved to WINDOWS/system32.

How can i do that?

Thanks in advance! :thumbup


Posted (edited)

@echo off

regsvr32 /s %SystemRoot%\system32\File.dll

move c:\filename %SystemRoot%\system32

If I understood you correctly :)

Edited by KingAFW
Posted (edited)

Yup that works.

Thank you! :)

Another 2 questions:

1:

How can i force delete a file with CMD?

2:

Im currently bissy creating my own office 2003 cd with all updates and stuff.

Now i will put some files i need in the image (which will be burned to a cd).

I got the image Office2003SP3NL.iso, in this image i got a directory called "myfiles".

I will burn this image to a cd.

What i want:

I want a cmd that copies all files in the "myfiles" directory(1), and it should copy them to my C:/ (local disk).

(1): "myfiles" directory is on the burned cd, so when its in the dvd-reader, and when i call the cmd it should start copying those file to C:/

How should my CMD look like?

Btw:

The CMD i also in the "myfiles" directory.

Thanks in advance! :)

Edited by Raoul90
Posted (edited)

Q1: (force delete a file, assuming it is not locked by any process)

General synatx is

del /F /Q yourfile.txt

The above syntax assuming you are deleting in current directory. If your .cmd file is not in current directory and it is in different path, just provide the full path to delete the file, maybe like this

del /F /Q "%systemdrive%\myfiles\yourfile.txt"

See del /? for help in cmdbox

Q2: Copy files

Syntax

md "%systemdrive%\myfiles" <----assuming systemdrive is C:\

copy /Y *.* "%systemdrive%\myfiles" <--- assuming u call the cmd file in <CDdrive>\myfiles directory

Open cmdbox, see copy /? and set (view environment variable) for more details

NOTE: if u want to copy files & subdir in myfiles folder, use xcopy

See xcopy /? for syntax

Command-line reference A-Z

Edited by Geej
Posted (edited)

The Delete thing works fine.

Thanks.

But i don't get the copying stuff.

I have got a "prepared image" (i only need to make it an image).

The prepared image contains all stuff including the "myfiles" directory.

In this "myfiles" directory i want a cmd that copies al items to C:/

In the "myfiles" directory there are no subfolders, just files .doc etc.

So when i burned the image and i go to "My Computer" and explore the cd then i go in the "myfiles" folder and i click the copy.cmd, then it should start copying the files inside the "myfiles" folder and the cmd should paste them at my %systemdrive%.

The CD-Drive Letter is never the same, also the %systemdrive% could be other then C:/.

edit:

Should it be something like this:

copy myfiles/example.doc %systemdrive%

?

When i put this in a cmd and start it from the root of the cd, is that gonna work?

Edited by Raoul90
Posted

Assuming copy1.cmd (avoid copy.cmd as it is similiar to cmd internal command copy) is at root CD and myfiles folder is only 1 level deep, then try something like this within copy1.cmd

cd myfiles

copy /Y *.doc C:\

What this means is that copy1.cmd is lauch from root of CD, it will navigate 1 level folder to myfiles folder.

Copy all of .doc files to C:\. I'm using absolute path, rather than relative one. Feel free to change to relative path if u have to.

Posted

I dont get it :P Im new with those commands so.

Clear things up a bit.

I am making an autoplay using AutoPlay Media Studio. I also have a button to call the cmd which copies the items from the Myfiles directory.

When i make the autoplay the files which should be copied are in:

CD\AutoPlay\Docs\Myfiles\files.doc

Maybee you could be a bit more specific to me what to type into the cmd?

Thank you. :)

Posted (edited)

Assumption : copy1.cmd is on your CD root and Drive E is your optical drive,

the full path to your .doc on your CD is E:\autoplay\docs\myfiles\files.doc

and u want to copy all .doc to C:\

cd autoplay\docs\myfiles
copy /Y *.doc C:\

The first command will navigate to the AutoPlay\Docs\Myfiles folder, then

The 2nd command will copy all .doc to C:\

U can also replace 2nd command as

copy /Y *.doc "%systemdrive%\"

To made things clearer, so your code can also be

cd autoplay\docs\myfiles
copy /Y *.doc "%systemdrive%\"

U mention "also the %systemdrive% could be other then C:/' which means u can only specific absolute drive letter if u wish to copy to D: , E: etc (other than %systemdrive%, which is usually C:)

*cd in my 1st command means change directory (DOS command). It is not a folder named CD (just to make it clearer)

If it is not correct assumption, then probably 1st command will be

cd cd\autoplay\docs\myfiles

Otherwise pls provide the full path to your .doc , including optical drive letter so that I can provide the correct command.

I hope u understand that to suggest a proper code that works for you, u need to be very specific in stating your full path that is on your CD.

Hope that helps.

Edited by Yzöwl
Codebox's changed to save screen real estate
Posted (edited)

Geej, thanks dude.

I got it working.

Thanks for the explanation. The first one with CD works perfectly. :D

:thumbup

Edited by Raoul90
Posted

Just for the record, the /Y switch for the copy command is NOT needed from batch:

http://www.ss64.com/nt/copy.html

NT 4 will overwrite destination files without any prompt, Windows 2000 and above will prompt unless the COPY command is being executed from within a batch script.

jaclaz

Posted

Thanks jaclaz for the extra info. Indeed it is.

I think can reduce to 1 single command: (instead of 2 command lines)

copy autoplay\docs\myfiles\*.doc C:\

Posted (edited)

One more question:

How can i copy a whole map/folder/ directory from the autoplay\docs\myfiles folder?

I have a map called "Pictures" and i want the whole directory to be copied so not only the files inside.

Edited by Raoul90
Posted

Read this:

http://www.ss64.com/nt/xcopy.html

You need to specify the name of both the source and target folders as in the given example:

To copy a folder:

XCOPY C:\utils D:\Backup\utils /i

To copy a folder including all subfolders.

XCOPY C:\utils\* D:\Backup\utils /s /i

adding if needed the /E switch

jaclaz

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...