Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Need some help on cmd batch file.

16 Jun 2013   #1
illusions

Windows 7 Ultimate x64
 
 
Need some help on cmd batch file.

Hi,

I would like to a batchfile that will work on both windows 7 and xp to do the following

copy /Y d:\document\folder1\file.ini d:\document\folder2\file.ini

however in xp it is my document, win7 is document


the shell command in win7
%windir%\explorer.exe shell:::{450d8fba-ad25-11d0-98a8-0800361b1103}\folder1
%windir%\explorer.exe shell:::{450d8fba-ad25-11d0-98a8-0800361b1103}\folder2
will provide the right path

how can I export that path to the copy command above ?


My System SpecsSystem Spec
.
16 Jun 2013   #2
UsernameIssues

W7 Pro SP1 64bit
 
 

Welcome to the Seven Forums.

This works for me on both operating systems:
Code:
copy "%userprofile%\my documents\folder1\file.ini" "%userprofile%\my documents\folder2\file.ini"
pause
That is why these hidden links exist...

Need some help on cmd batch file.-my-docs.png

...so that programs (and batch files) can make use of them.


My System SpecsSystem Spec
16 Jun 2013   #3
illusions

Windows 7 Ultimate x64
 
 

Thanks UsernameIssues for the suggestion but when I tried it I got error message please refer to the picture.


Attached Thumbnails
Need some help on cmd batch file.-error.jpg  
My System SpecsSystem Spec
.

16 Jun 2013   #4
UsernameIssues

W7 Pro SP1 64bit
 
 

I was hoping that you had moved the entire profile to the D drive per this procedure:
User Profile - Change Default Location
That makes the %userprofile% variable point to the correct folder... it should work on XP as well.


Try
Code:
IF EXIST "d:\document\folder1" copy "d:\document\folder1\file.ini" "d:\document\folder2\file.ini" /Y
IF EXIST "d:\my document\folder1" copy "d:\my document\folder1\file.ini" "d:\my document\folder2\file.ini" /Y
My System SpecsSystem Spec
16 Jun 2013   #5
illusions

Windows 7 Ultimate x64
 
 

Thanks the if exist method does the job.

When I first installed win7, I only change the following folders to d drive (favorites, documents, music, video), to g drive (download folder).

Using this method #2
User Folders - Change Default Location

Instead of moving the whole default location of User Profile.

I guess that is why %userprofile% environmental variable does not provide the right path.

Refer to this 2 registry info.


Attached Thumbnails
Need some help on cmd batch file.-pic1.jpg   Need some help on cmd batch file.-pic2.jpg  
My System SpecsSystem Spec
16 Jun 2013   #6
UsernameIssues

W7 Pro SP1 64bit
 
 

Glad that you got it working... and yes, changing folders that way is why the OS variable does not work for you. The funny thing is: I had constructed my first post in this thread using the IF EXIST code... but then I got to wondering if you had a lot of different files/folders to be copied - so I changed it to use that OS variable.
My System SpecsSystem Spec
Reply

 Need some help on cmd batch file.




Thread Tools Search this Thread
Search this Thread:

Advanced Search




Similar help and support threads
Thread Forum
How can I write a batch file that opens a file in a program?
I wrote this batch file which does what I want it to do so far. @echo off "C:\Users\xxxxxx\Documents\HideTaskbar\HideTaskbar.exe" "C:\Program Files (x86)\VideoLANold\VLC\vlc.exe" "C:\Users\xxxxxx\Documents\HideTaskbar\ShowTaskbar.exe" exit
General Discussion
I need a batch file to open a random file within a certain folder/path
I want a batch to select and open a random link file in a folder i have. All the links are music videos I like to listen to, and I kind of want to just have an option for 'surprise me!'. I can change the file names if I have to, and I have a basic batch file ability. I know the simple commands,...
General Discussion
How to run a batch file at logoff & some batch scripting help please
Hiya, I'd just like to run a simple batch file at logoff to backup some settings. I plan to use Robocopy, which is what i use to more thorough backups. Two questions: 1. How make it run by clicking Start > Shutdown? (i realise i could make a shutdown batch file and run it instead, but i'd...
Backup and Restore
Batch File that grabs file names from folder to insert into batch file
Ok I'm totally at a loss on how to word this so I'm just going to write it out the best that I can... :confused: First I have a batch file that I'm writing that will convert mp4 files to mp3 files (I have a lot) for a buddies band using ffmpeg. Here's the code that I'm using: ffmpeg -i...
General Discussion
batch file open file for program in the startup folder
I have a computer that is a drone specifically for an outside LED sign. This computer is designed to never shut off and doesn't have any other program on it besides Operating System and the sign software. I need to create a batch file that I can place in the "start-up" folder that will open the...
General Discussion
How to create a batch file that will move files based on the file type
How to create a batch file that will move files based on the file type? My Requirement : I need a batch file to copy all .doc files in all my HardDisk to a removable disk say (Z: drive) . Can anyone make it possible using a batch file?Please...Its urgent...
General Discussion


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 03:19.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App