Jump to content

64Bit XP Defrag Help - Please


RoBo1
 Share

Recommended Posts

Hello - I use this script in my environment and it works great for my XP client workstations. It allows the user without Administrator Privleges to run Windows Defrag. I have tried changing to various combinations and directories and can not get it to work for a XP 64Bit workstation.

Can someone please assist me with correcting this script so that it will work? Thanks so much

Thanks to the original Author as well.

;Listing 1: Defrag.aut

; Language: US English
; Author: Tom Watson (tom_watson@jabil.com)
; Script Function:
; Run Disk Defragmenter.
;
BlockInput ( 1 )
WinMinimizeAll ( )
Sleep ( 1000 )

; Set the RunAs parameters to use local adminstrator account
RunAsSet("Administrator", @Computername, "password")

Run ( "C:\WINDOWS\system32\mmc.exe C:\WINDOWS\system32\dfrg.msc" )

; Reset user's permissions
RunAsSet()

I have tried to change the \system32\ to \SysWOW64\ and copy the defrag.exe to that location and it still will not work.

I am open to any suggestions.

Thanks again :D

Link to comment
Share on other sites

You just need to compile the script as a 64bit application via CTRL+F7 in SciTE.

If you want one executable to run on 32 and 64bit OSses, you need to have a wrapper script in 32bit which includes both the 32 and 64bit versions of the real script as ressources. Depending on the host's OS the right one needs to be extracted to %TEMP% and started by the wrapper - done.

On the 64bit OSses there is some kind of folder redirection happening when a 32bit application tries to start specific Windows executables or to access the Windows registry.

Edited by cherdeg
Link to comment
Share on other sites

Found the fix and this is the completed Script - feel free to use if needed! Tested and Working! :D

Thanks to cherdeg for a fast response!

THIS IS THE MISSING LINE THAT WAS NEEDED

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

;Listing 1: Defrag.aut

; Language: US English
; Author: Tom Watson (tom_watson@jabil.com)
; Script Function:
; Run Disk Defragmenter.
;
BlockInput ( 1 )
WinMinimizeAll ( )
Sleep ( 1000 )

; Set the RunAs parameters to use local adminstrator account
RunAsSet("Administrator", @Computername, "password")

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

Run ( "C:\WINDOWS\system32\mmc.exe C:\WINDOWS\system32\dfrg.msc" )

; Reset user's permissions
RunAsSet()

Edited by RoBo1
Link to comment
Share on other sites

Hey WTF ?!?

This is MEGA-COOL, why didn't I find that DLL-call when I was searching my bloody ass off as I had the same problem? Where did you find it?

So this time it's reversed: YOU asked the question and YOU also receive the thanks - Thank you very much for that great line, it will save me lots of efforts in the future...

Regards,

Chris

Link to comment
Share on other sites

Hey WTF ?!?

This is MEGA-COOL, why didn't I find that DLL-call when I was searching my bloody ass off as I had the same problem? Where did you find it?

So this time it's reversed: YOU asked the question and YOU also receive the thanks - Thank you very much for that great line, it will save me lots of efforts in the future...

Regards,

Chris

Found a post where someone suggested for a 64Bit Script to search for sysWow64 redirect and BAM found it - Tried it - Worked! :D

I love AUTOIT :D

Edited by RoBo1
Link to comment
Share on other sites

In the help file :D

http://www.autoitscript.com/autoit3/docs/intro/64-bit_support.htm

Hey, not everybody learns the helpfile by rote on every new release. If you do, I'll directly ask you the next time I have a problem. I studied the helpfile intensely when 3.1 was the latest release...is it possible you can forgive me my unspeakably evil mortal sin? I, ahh, beg you!

Why not let RoBo1 and me have some simple fun between newbs?

Edited by cherdeg
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...