Batch/Command file to copy file to c:\windows\sysWOW64


  1. Posts : 11
    w10
       #1

    Batch/Command file to copy file to c:\windows\sysWOW64


    Hi there,

    I tried creating a batch file on a usb stick, but it could not copy files to a windows system folder.
    I require administration run to execute this copy, but when i ran using administration, it doesn't know where to find the files on the usb stick.

    The usb stick has the following 2 files. The usb stick changes drive letter depending whose pc it is running at.
    1. At root .\README.txt
    2. .\folderA\testfile.txt

    In my batch file (textcopy.bat), the following script :
    copy README.txt c:\windows\syswow64
    copy ,\folderA\testfile.txt c:\windows\syswow64

    Ideas?

    The part i think it is missing when running as administrator is specifying the current location of the file.
      My Computer


  2. Posts : 264
    Windows 10
       #2

    is there a typo on your second line?
      My Computer


  3. Posts : 11
    w10
    Thread Starter
       #3

    xaccell said:
    is there a typo on your second line?
    Ah yes, its a typo in the forum here.
    copy .\folderA\testfile.txt c:\windows\syswow64
      My Computer


  4. Posts : 16,712
    Windows 10 Home x64 Version 22H2 Build 19045.4170
       #4

    SysWoW64 is owned by the virtual user "TrustedInstaller" and access permissions for other users, including Administrators, are severely limited.

    Please might I just check why you are trying to copy a text file there / what outcome are you trying to achieve / what will that text file then allow you to do that you could not do before?
    Knowing that would help people to provide more helpful responses.

    Denis
      My Computer


  5. Posts : 11
    w10
    Thread Starter
       #5

    Try3 said:
    SysWoW64 is owned by the virtual user "TrustedInstaller" and access permissions for other users, including Administrators, are severely limited.

    Please might I just check why you are trying to copy a text file there / what outcome are you trying to achieve / what will that text file then allow you to do that you could not do before?
    Knowing that would help people to provide more helpful responses.

    Denis
    Yes, the textFile was just a sample filename. I actually have 2 custom dlls that need to reside in that folder.
    Currently, I have an application that runs on usb stick (Usually it installs on the c drive). To fully run this application, it requires two dll file to reside in that folder.

    I have a batch file where it will popup and ask user where they want to copy the application file to, but this is the only two files currently that i can't use a batch file to copy. I had to tell the user to copy manually instead.
      My Computer


  6. Posts : 456
    Windows 10
       #6

    The problem is that when you run the batch as default user you run the batch from where it is let's say e:\mybatch.bat. The batch can see Readme.txt and \FolerA\Testfile.txt because it is on the same drive as the files. When you run the batch as Admin you get automatically redirected to the path C:\windows\System32.

    Readme.txt and \FolderA\Testfile.txt are not in System32 thus the batch can't see them.

    To always point to the directory Where the batch is you can use: %~0dp

    ---------------------------------------------------------------------
    @echo off

    net session >nul 2>&1 || (powershell start -verb runas '%~0' &exit /b)

    copy "%~dp0README.txt" "c:\windows\syswow64"
    copy "%~dp0folderA\testfile.txt" "c:\windows\syswow64"

    if /i exist "c:\windows\syswow64\readme.txt" Echo Readme.txt copied successfully
    if /i exist "c:\windows\syswow64\testfile.txt" Echo testfile.txt copied successfully

    pause
    -------------------------------------------------------------------------------------------

    * The line with net session...asks for elevation in case you forget to right click & run as admin...
      My Computer


  7. Posts : 264
    Windows 10
       #7

    we are to assume that the files you want to copy are in the root of the pendrive where the BAT file is also located, right?

    If so, the above batch should work.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 02:45.
Find Us




Windows 10 Forums