Jump to content

Copy text from Command Prompt


DigDeep
 Share

Recommended Posts

Hi,

I think I am doing something wrong here to add the '$Command' variable.

Everytime I run this it gives me message: C:\Windows\SysWoW64\manage-bde.exe is not recognized.

 

Can someone please help me in arranging the below $Status.

$Command = @SystemDir & '\manage-bde.exe -status c:'

$Status = Run(@ComSpec & ' /c "' & $Command, "", @SW_HIDE, $STDERR_MERGED)

ProcessWaitClose($Status)

$output = StdoutRead($Status)

MsgBox(0, "Status", $output)

 

Link to comment
Share on other sites

Is the process you are trying to run located in C:\windows\Syswow64?  Or is it located in system32?  Try checking to see if you are compiling the application as a x86 or x64 application.  The SysWow64 folder is the Windows System folder (system directory) for 32-bit files, while System32 is the Windows System folder (system directory) for 64-bit files.  Try compiling the exe as a 64-bit application and see if the error occurs again.

Edited by MattHiggs
Link to comment
Share on other sites

@MattHiggs

This is something I had already tested to compile in the 64 bit and it does work there but compiling with 32 bit is not. Sorry for not providing this update above.

However, I have too many codes running as of now which are all compiled as 32-bit and they have been assigned like the below example with no issues.

The above code is the only 1 which only runs when compiling with @SystemDir_Path instead of $SystemDir_Path and compiling as 64-bit.

Select
    Case @OSArch = "x86"
        $SystemDir_path = @SystemDir
    Case @OSArch = 'x64'
        $SystemDir_path = 'c:\windows\sysWOW64'
EndSelect

$Command = $SystemDir_path & '\commandline to run'
RunWait(@ComSpec & ' /c "' & $Command & '" additional commandlines needed', "", @SW_HIDE)

 

Appreciate if you can look into this once.

 

 

Link to comment
Share on other sites

I see what is the issue here now...

all my other codes are working fine because msiexec is a part of both system32 and syswo64 so the below variable works out.

$SystemDir_path

 

But my Top command is looking for 'manage-bde.exe' which is only in system32 folder so the above variable is not working.

Can you please help in arranging the below code. I have tried to re-arrange it... and the 1st MsgBox does show the @Comspec as C:\Windows\System32

But the final MsgBox comes up blank.

$Command = 'manage-bde'

$Status = RunWait(@ComSpec & ' /c "' & $Command & '"  -status C:', "", @SW_HIDE, $STDERR_MERGED)

MsgBox(0, "", @ComSpec & ' /c "' & $Command & '"  -status C:')

ProcessWaitClose($Status)

$output = StdoutRead($Status)

MsgBox(0, "Status", $output)

 

When in the command prompt it should look like this:

C:\WINDOWS\system32>managebde.exe -status c:

Link to comment
Share on other sites

2 hours ago, DigDeep said:

I see what is the issue here now...

all my other codes are working fine because msiexec is a part of both system32 and syswo64 so the below variable works out.

$SystemDir_path

 

But my Top command is looking for 'manage-bde.exe' which is only in system32 folder so the above variable is not working.

Can you please help in arranging the below code. I have tried to re-arrange it... and the 1st MsgBox does show the @Comspec as C:\Windows\System32

But the final MsgBox comes up blank.

$Command = 'manage-bde'

$Status = RunWait(@ComSpec & ' /c "' & $Command & '"  -status C:', "", @SW_HIDE, $STDERR_MERGED)

MsgBox(0, "", @ComSpec & ' /c "' & $Command & '"  -status C:')

ProcessWaitClose($Status)

$output = StdoutRead($Status)

MsgBox(0, "Status", $output)

 

When in the command prompt it should look like this:

C:\WINDOWS\system32>managebde.exe -status c:

I think you might be misunderstanding something as well.  Initially you were using the "@systemDir" macro as the value for the system directory.  This macro will be set to equal either (on a 64 bit machine) "C:\Windows\Syswow64" if compiled as a 32-bit application, or "C:\Windows\system32" if compiled as a 64-bit application.  There is no need for you to specifically define the paths like you did in your script, as the "@SystemDir" macro does this for you depending on how you compile the script.  Does that make since?

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