RoBo1 Posted September 29, 2009 Share Posted September 29, 2009 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 muchThanks 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 Link to comment Share on other sites More sharing options...
cherdeg Posted September 29, 2009 Share Posted September 29, 2009 (edited) 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 September 29, 2009 by cherdeg Link to comment Share on other sites More sharing options...
RoBo1 Posted September 29, 2009 Author Share Posted September 29, 2009 (edited) Found the fix and this is the completed Script - feel free to use if needed! Tested and Working! 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 September 29, 2009 by RoBo1 Link to comment Share on other sites More sharing options...
cherdeg Posted September 29, 2009 Share Posted September 29, 2009 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 More sharing options...
RoBo1 Posted September 29, 2009 Author Share Posted September 29, 2009 (edited) 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, ChrisFound a post where someone suggested for a 64Bit Script to search for sysWow64 redirect and BAM found it - Tried it - Worked! I love AUTOIT Edited September 29, 2009 by RoBo1 Link to comment Share on other sites More sharing options...
TurionAltec Posted September 29, 2009 Share Posted September 29, 2009 In the help file http://www.autoitscript.com/autoit3/docs/intro/64-bit_support.htm Link to comment Share on other sites More sharing options...
cherdeg Posted September 30, 2009 Share Posted September 30, 2009 (edited) In the help file http://www.autoitscript.com/autoit3/docs/intro/64-bit_support.htmHey, 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 September 30, 2009 by cherdeg Link to comment Share on other sites More sharing options...
Richard Robertson Posted September 30, 2009 Share Posted September 30, 2009 RunAsSet is no longer a function. You are highly recommended to upgrade. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now