1.

Solve : COPY MYFILE.TXT %userprofile%\Desktop???

Answer»

I was on the internet, learning(TRYING to learn) about variables, but I still don't really get it. One of the examples were:
Code: [Select]COPY MYFILE.TXT [highlight]%userprofile%[/highlight]\DesktopWhat would that do? Especially the highlighted part.That would copy the file onto the username's desktop.

Variables are objects whose values can change. Very useful in BATCH and programming.Some environment variable like userprofile are preset by the operating system. To get a list of current environment variables and there values OPEN a command prompt and type:

C:>set

You will get a list of all variables.
You can set a variable like this:

C:>set MYVAR=hello user

you can then use the variable like this:

C:>echo %myvar%

which will display on the screen:

hello user

Hope this GETS you started. For more info about the set command and the cool STUFF you can do with it type:

C:>set /?

Or just look up the command reference in the internet here:

http://dostips.cmdtips.com/DosCommandRef.htm#set

Hope this helps

Finally! After all these years I finally get how to use the SET command!!! thanks!!, I get it all now!! :exclamation Quote

Some environment variable like userprofile are preset by the operating system. To get a list of current environment variables and there values open a command prompt and type:

C:>set

You will get a list of all variables.
You can set a variable like this:

C:>set myvar=hello user

you can then use the variable like this:

C:>echo %myvar%

which will display on the screen:

hello user

Hope this gets you started. For more info about the set command and the cool stuff you can do with it type:

C:>set /?

Or just look up the command reference in the internet here:

http://dostips.cmdtips.com/DosCommandRef.htm#set

Hope this helps ;)

If I did that set thing on my computer to create a variable, would it work on someone elses computer. (if not, is it possible to change it on more than 1 computer?)The SET command works only on the local machine. Keep in mind that the SET command does not list all the variables available. %date%, %time%, %cd%, %errorlevel% are all available on some machines but you won't find them in any SET listing. Generally variables that are SET, live only for the duration of the command or cmd window and variables SET in one window are not available in another command or cmd window. As always, there are ways to get around this.

8-)thanks :exclamation


Discussion

No Comment Found