We help IT Professionals succeed at work.

vb6 how to copy file to system32 in win7 64bit

daypro asked
below vb6 code
  Dim fs As New FileSystemObject
fs.CopyFile "c:\Test.TXT", "C:\Windows\SysWOW64\Test.txt"
 fs.CopyFile "c:\Test.TXT", "C:\Windows\System32\Test.txt"
why fs.CopyFile "c:\Test.TXT", "C:\Windows\SysWOW64\Test.txt" can work
but   fs.CopyFile "c:\Test.TXT", "C:\Windows\System32\Test.txt" can't work

which is to say
after execute program,in C:\Windows\SysWOW64 can find Test.txt
but C:\Windows\System32 can't find Test.txt

how vb6 copy file to Win7 64 bit c:\windows\system32\    directory ?


Watch Question

I think you will need to provide admin rights to copy to System32

Try make your project executable  for example  test.exe
then right click on it  ( or Shift + right click  )  then choose run as administrator , and see if it going to be copied to system32  or not
suman_g4Manager - IT

try executing the script from an elevated command prompt.
hope this helps.


thanks for the reply

1,I have tried  run as administrator  but not working
2 could suman_g4: give an example of how to elevated command prompt

suman_g4 meant --> go to start -->  in the search box type cmd --> right click on the cmd icon and choose run as administrator  
you will have the  command line window --> type the command you want  ( like this )

copy  c:\Test.TXT  C:\Windows\System32\Test.txt  


thanks for the reply
in fact ,I want to use vb6 to make a install program
first step is copy four file uniime.dll,miniime.tpl,chinese.ime,chinese.tbl
to windows/system32 folder

in win7 32 bit the code
fs.CopyFile "c:\uniime.dll", "C:\Windows\System32\uniime.dll"  works ok

but in win7 64 bit after the same vb6 code
fs.CopyFile "c:\uniime.dlll", "C:\Windows\System32\uniime.dll" or
fs.CopyFile "c:\test.txt", "C:\Windows\System32\test.txt"

i check C:\Windows\System32
still  can't see uniime.dll or test.txt (even run as administraor)

but use command line window dos command
copy c:\uniime.dll C:\Windows\System32\uniime.dll
or copy c:\test.txt C:\Windows\System32\test.txt
works ok

Try manual copy also works ok

Try below vb6 code
shell "cmd.exe /c  copy c:\test.txt C:\Windows\System32\test.txt"
not ok,
 in windows/system32 can't see copy result,

is there any way to use vb6 code
to copy file to c:\windows\system32 folder in win7 64 bit


Amro OsamaDevelopment, GIS Consultant - Haram Presidency

since vb6 is 32 bit, and running it will run in 32bit mode under a 64bit system, it will run in WOW64 mode.

that's why your application has only access to the SysWOW64.

but why do you need it to reside in System32 Instead, you could access it from SysWOW64 directly.
maybe im missing something, please correct me.
Amro OsamaDevelopment, GIS Consultant - Haram Presidency

if you want instead, you can run an api to get the system32 of the operating system
so when you run the application, it will automatically check the system32 folder for you.
in a 32bit OS it will return System32, in a 64OS it will return Sys64WOW

and as i told you before, your application is 32bit, so you should not worry about the folder, all what you need is the system folder returned by the OS.

do you want me to provide you with the code?


thanks OHDev2004 help,
my application install to  win7 64 bit need to  copy to both folder(syswow64 and system32)
then it can run correctly,

if I only copy to syswow64,(in 32 bit program like word 2003 run ok .but 64 bit program like notepad can not run my chaine input ime program)

now if i can copy file  to system32 in win7 64 bit ,
then I can success finish my install ime program both compatible 32bit application(like word 2003)
 and 64 bit application(like notepad) in win7 64bit

so is there any solution  to copy file to system32 folder in win7 64 bit use vb6 32bit program?

also I need OHDev2004 provide me  the code of
system folder returned by the OS,

thanks ,all the best



correct :chaine type wrong(chinese)
chaine input ime program
is chinese input ime prgram

Development, GIS Consultant - Haram Presidency
Ok, now i understand why you need to copy it to both system folders.

this behavior is like i told you before, but fortunely there is an API to turn it off/on
Credits go to this MSDN Page:

'API Declaration for WOW64 Restriction
Private Declare Function Wow64DisableWow64FsRedirection Lib "kernel32" (ByRef OldValue As Long) As Long
Private Declare Function Wow64RevertWow64FsRedirection Lib "kernel32" (ByRef OldValue As Long) As Long

Private OldValue As Long

'Returns True  when the restriction is On (Default)
'Returns False when the restriction is Off
Public Property Get Wow64Restiction() As Boolean
    Wow64Restiction = IIf(OldValue > 0, False, True)
End Property

'Pass False to turn the Restriction Off,
'Pass True to turn it On(On by default)
Public Property Let Wow64Restiction(ByVal value As Boolean)
    On Error Resume Next
    'Turn Restruction Off
    If value = False Then
        Wow64DisableWow64FsRedirection OldValue
    'Turn Restriction On
    ElseIf value = True And OldValue > 0 Then
        Wow64RevertWow64FsRedirection OldValue
        OldValue = 0
    End If
End Property

Public Sub Test()

    'First call will copy the files to SysWOW64

    'Turn Restriction Off
    Wow64Restiction = False

    'Second call will copy the files to System32 after the restriction was turned off.

    'Restore the restriction back On
    Wow64Restiction = True
End Sub

Public Sub CopyFiles()
    fs.CopyFile "c:\uniime.dlll", "C:\Windows\System32\uniime.dll"
    fs.CopyFile "c:\test.txt", "C:\Windows\System32\test.txt"
End Sub

Open in new window


thanks OHDdev2004's Code,
I have tested and success copy file to system32 in win7 64 bit
it's really perfect solution
Amro OsamaDevelopment, GIS Consultant - Haram Presidency

your welcome, glad it helped out.
just be sure to turn the restriction Back on like in the sample, because this is system wide,
and any 32bit application will be affected.
have a nice day!


ok,I will turn the restriction Back on (don't affect another 32 bit application)
thanks again

all the best