Jump to content

how to launch cmd in 64 bits from a 32 bit AutoIT exe?


rodent1
 Share

Recommended Posts

Friends,

A script I am working on calls a commandline utility called lpr.exe. It allows sending files to a printer with an IP address.

My script needs to work on both 32 and 64 bit systems.

on my 64 bit system, the only LPR.exe is a 64 bit app, and if I use a command such as

RunWait(@ComSpec & " /K lpr.exe -S " & $IPAddress & " -P strict " & $FileName, @ScriptDir)

I get an error in the command window telling me there is no lpr.exe command.

If I compile my script in 64 bits, it works fine.

But then of course that script wouldn't work on a 32 bit system.

I could use kludges, such as installing a "lpr32.exe" copied from a 32 bit system on a 64 bit system, and compile the script in 32 bits, or I could even have a 64 and a 32 bit version of the same script. But then, many of my users have no idea if their system is a 32 or 64 bit one, and I'm trying to keep things simple.

Is there a way to use RunWait or something similar in such a way that a 64 bit cmd.exe would be called from a 32-bit compiled script? I kind of doubt that, but someone out there might dream up a way...

Thanks

Link to comment
Share on other sites

  • Moderators

Hi, rodent1. Look in the helpfile for @OSArch. You could add an If statement..

If @OSArch = "X64" Then
RunWait(@ComSpec & " /K lpr.exe -S " & $IPAddress & " -P strict " & $FileName, @ScriptDir)
Else
RunWait(@ComSpec & " /K lpr.exe -S " & $IPAddress & " -P strict " & $FileName, @ScriptDir)
EndIf

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

See if this helps.

Note: Only compile your script to 32 bit.

If @OSArch = "X64" Then
DllCall('kernel32.dll', 'int', 'Wow64EnableWow64FsRedirection', 'int', 0)
RunWait(@ComSpec & " /K lpr.exe -S " & $IPAddress & " -P strict " & $FileName, @ScriptDir)
DllCall('kernel32.dll', 'int', 'Wow64EnableWow64FsRedirection', 'int', 1)
Else
RunWait(@ComSpec & " /K lpr.exe -S " & $IPAddress & " -P strict " & $FileName, @ScriptDir)
EndIf
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

×
×
  • Create New...