MBrand Posted August 18, 2009 Share Posted August 18, 2009 (edited) Hi there since hours I can't find the solution to this problem: I try to check with defrag c: -a if defragmentation is necessary. $str_l = "C:\" Local $RunCMD = @ComSpec & " /c " & @SystemDir & "\defrag.exe " & $str_l & " -a" Local $f01 = Run($RunCMD, @SystemDir, @SW_MINIMIZE, $STDERR_MERGED + $STDOUT_CHILD) That works fine with XP and Server 2003 32bit. When I start it on a 2003 64 bit machine, I always get the following error: 'C:\WINDOWS\SysWOW64\defrag.exe' is not recognized as an internal or external command,operable program or batch file. So I tried several different ways to give the correct path with the run command, like @WindowsDir & "\system32\defrag.exe", also in the Run-Workingdir Parameter without any success: (and C:\WINDOWS\system32\defrag.exe is definitely the correct path!) 'C:\WINDOWS\system32\defrag.exe' is not recognized as an internal or external command,operable program or batch file. The Example code works, when I compile the script for x64, but then it won't work on x32 machines. But I need ONE script for both systems.... Any suggestions? Thanks a lot! Edited August 18, 2009 by MBrand Link to comment Share on other sites More sharing options...
BinaryBrother Posted August 18, 2009 Share Posted August 18, 2009 (edited) Replace @SystemDir with @HomeDrive & "\Windows\System32" That will work on 90% of your client base. Otherwise, your going to need to differentiate between x32 and 64. Maybe you could pack 2 versions of your script in a 'loader' using "FileInstall()" FileInstall("C:\32bitcompile.exe",@Tempdir & "\32bit.exe") FileInstall("C:\64bitcompile.exe",@Tempdir & "\64bit.exe") If @OSArch = "x64" Then Run("C:\64bitcompile.exe") Else Run("C:\32bitcompile.exe") EndIf These are just quick ideas. >_< P.S. Make your loader 32bit so it will run on both systems. Edited August 18, 2009 by BinaryBrother SIGNATURE_0X800007D NOT FOUND Link to comment Share on other sites More sharing options...
MBrand Posted August 18, 2009 Author Share Posted August 18, 2009 Hi, thanks for the fast reply. I found a solution for the same issue in a python Forum. It's probably a Windows problem. It wont't work even with the proper & full path. So I copied defrag.exe from system32 to the sysWOW64 directory and it worked immediately. Added a hint for the user: If @OSArch = "x64" Then $szMsg = $szMsg & " ggfls. defrag.exe ins DIR sysWOW64 kopieren" EndIf Link to comment Share on other sites More sharing options...
BinaryBrother Posted August 18, 2009 Share Posted August 18, 2009 Just for the record, it's not a Windows 'problem' this is how a 64bit OS deals with a program built for a 32bit architecture... sysWOW64 works a little like emulation. The word 'emulation' is arguable, but none the less... The results you are seeing are quite normal. >_< Glad to see you figured it out. SIGNATURE_0X800007D NOT FOUND Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted August 18, 2009 Share Posted August 18, 2009 Hi, thanks for the fast reply. I found a solution for the same issue in a python Forum. It's probably a Windows problem. It wont't work even with the proper & full path. So I copied defrag.exe from system32 to the sysWOW64 directory and it worked immediately. Added a hint for the user: If @OSArch = "x64" Then $szMsg = $szMsg & " ggfls. defrag.exe ins DIR sysWOW64 kopieren" EndIf Search for Wow64DisableWow64FsRedirection, it would be the proper solution. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
MBrand Posted August 20, 2009 Author Share Posted August 20, 2009 In order to have a proper solution I tried DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "int", 1) at the top of the code but it didn't work... 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