Jump to content
Sign in to follow this  
MBrand

solved: run: 32bit ok - 64bit fails with "..is not recognized as an internal or external command..."

Recommended Posts

MBrand

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 by MBrand

Share this post


Link to post
Share on other sites
BinaryBrother

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 by BinaryBrother

Share this post


Link to post
Share on other sites
MBrand

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

Share this post


Link to post
Share on other sites
BinaryBrother

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. :(

Share this post


Link to post
Share on other sites
AdmiralAlkex

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.

Share this post


Link to post
Share on other sites
MBrand

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...

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.