Need some help on cmd batch file.


  1. Posts : 21
    Windows 7 Ultimate x64
       #1

    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 Computer


  2. Posts : 10,485
    W7 Pro SP1 64bit
       #2

    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 Computer


  3. Posts : 21
    Windows 7 Ultimate x64
    Thread Starter
       #3

    Thanks UsernameIssues for the suggestion but when I tried it I got error message please refer to the picture.
    Attached Thumbnails Attached Thumbnails Need some help on cmd batch file.-error.jpg  
      My Computer


  4. Posts : 10,485
    W7 Pro SP1 64bit
       #4

    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 Computer


  5. Posts : 21
    Windows 7 Ultimate x64
    Thread Starter
       #5

    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 Attached Thumbnails Need some help on cmd batch file.-pic1.jpg   Need some help on cmd batch file.-pic2.jpg  
      My Computer


  6. Posts : 10,485
    W7 Pro SP1 64bit
       #6

    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 Computer


 

  Related Discussions
Our Sites
Site Links
About 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 05:56.
Find Us