Jump to content

Can't make changes inside System32/drivers


mikephn
 Share

Recommended Posts

I'm trying to automate an installation and I need to copy a new .sys to system32/drivers.

FileCopy and FileMove seem to make no changes, the file doesn't appear there after copying. Oddly enough, FileExists will tell me the file is there, when it's clearly not. The program that requires this .sys to be present also doesn't start.

I have all files visible, including system, and I'm requesting admin rights at the beginning of the script. I run Win7 64-bit.

So far I can only do it with a .bat being run by AutoIt, which is a bit pointless.

Can anybody offer a solution and/or explanation?

Many thanks

Mike

Link to comment
Share on other sites

@mikephn

If your script runs/is compiled as 32-bits code, Win 7 will redirect ALL your 'operations' on system32 to sysWOW64 ...

So you might want to take a look there.

Extremely logical, isn't it ? (64-bit code in system32, 32-bits in sysWOW64) ;)

HTH,

wim

Link to comment
Share on other sites

@mikephn

If your script runs/is compiled as 32-bits code, Win 7 will redirect ALL your 'operations' on system32 to sysWOW64 ...

So you might want to take a look there.

Extremely logical, isn't it ? (64-bit code in system32, 32-bits in sysWOW64) ;)

HTH,

wim

This could be it too. To fix this, make your destination:

$dest = @WindowsDir & "\System32\Drivers\"
Edited by gerwim
Link to comment
Share on other sites

This could be it too. To fix this, make your destination:

True, but if you want to install 64 bit drivers, you might as well compile your script

as 64 bit - so it won't accidentally f*** up a 32 bit system.

whim

Link to comment
Share on other sites

The program that needs this .sys needs to have it in System32, and depending on the OS (64/32) I have two versions of the file to copy. I'm checking @OSArch to determine which one to copy, but the script needs to run on both 32 and 64 bit systems.

My path actually is based on the Windows directory, because I also noticed that the system directory AutoIt gives is for sysWOW64. So my command is:

FileCopy(@WindowsDir & "\System32\drivers\64b.sys", @WorkingDir & "\Win64\64b.sys", 9)

FileExists(@WindowsDir & "\System32\drivers\64b.sys") returns 1, but the file is not there. It also doesn't appear in sysWOW64.

Link to comment
Share on other sites

This is only (un)proper redirection, nothing more. Use functions for disabling/enabling redirection an all should work fine.

String \System32 is interpreted differently depending on... what it depends.

The line is:

DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "int", 1)

Worked like a charm. Thanks a lot everyone!

Link to comment
Share on other sites

  • 8 months later...

The line is:

DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "int", 1)

Worked like a charm. Thanks a lot everyone!

Sorry to necro-post a little, but this helped me SOOO much that I had to acknowledge it!! I was trying everything reasonable, then some and some dumb stuff too like trying to set attributes and taking ownership before finding that FileGetSize was returning 0! The above DllCall made everything fall in to place!

BTW, Win7 x64

THANKS!!!!!

Ian

My projects:

  • IP Scanner - Multi-threaded ping tool to scan your available networks for used and available IP addresses, shows ping times, resolves IPs in to host names, and allows individual IPs to be pinged.
  • INFSniff - Great technicians tool - a tool which scans DriverPacks archives for INF files and parses out the HWIDs to a database file, and rapidly scans the local machine's HWIDs, searches the database for matches, and installs them.
  • PPK3 (Persistent Process Killer V3) - Another for the techs - suppress running processes that you need to keep away, helpful when fighting spyware/viruses.
  • Sync Tool - Folder sync tool with lots of real time information and several checking methods.
  • USMT Front End - Front End for Microsoft's User State Migration Tool, including all files needed for USMT 3.01 and 4.01, 32 bit and 64 bit versions.
  • Audit Tool - Computer audit tool to gather vital hardware, Windows, and Office information for IT managers and field techs. Capabilities include creating a customized site agent.
  • CSV Viewer - Displays CSV files with automatic column sizing and font selection. Lines can also be copied to the clipboard for data extraction.
  • MyDirStat - Lists number and size of files on a drive or specified path, allows for deletion within the app.
  • 2048 Game - My version of 2048, fun tile game.
  • Juice Lab - Ecigarette liquid making calculator.
  • Data Protector - Secure notes to save sensitive information.
  • VHD Footer - Add a footer to a forensic hard drive image to allow it to be mounted or used as a virtual machine hard drive.
  • Find in File - Searches files containing a specified phrase.
Link to comment
Share on other sites

  • 3 years later...

I'll Necro it again :) Just fixed my issue.

So strange as I was doing a filecopy and not using any macros I was using a defined file path.

In this case my code:

#RequireAdmin

;Disabled Auto Push to 32bit Location
DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "int", 1)

FileInstall("C:\My Places\Scripting\AutoIT\My Scripts\Disable Flash Update\mms.cfg", @TempDir & "\mms.cfg", 1)

If FileExists("C:\Windows\SysWOW64\Macromed\Flash\") Then
    FileCopy(@TempDir & "\mms.cfg", "C:\Windows\SysWOW64\Macromed\Flash\mms.cfg", 1)
Else
EndIf

If FileExists("C:\Windows\System32\Macromed\Flash\") Then
    FileCopy(@TempDir & "\mms.cfg", "C:\Windows\System32\Macromed\Flash\mms.cfg", 1)
Else
EndIf

Just a little script to push the mms.cfg file to disabled auto updated on Adobe Flash.

My question now is this, are there any ill effects in running that dllcall, like do I need to re-enable it after I have finished my script?

Edited by ViciousXUSMC
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...