[26 Oct 2011] Executing a Command in Windows using Execute()

Contains all messages from the Hollywood mailing list between 01/2006 and 08/2012
Locked
PEB
Posts: 569
Joined: Sun Feb 21, 2010 1:28 am

[26 Oct 2011] Executing a Command in Windows using Execute()

Post by PEB »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Wed, 26 Oct 2011 20:40:01 -0000

I'm trying to execute a command on a Windows machine through my Hollywood program using Execute(); but Windows thinks I'm trying to find a file or directory with the name of the command. So through the Windows CLI the command "systeminfo >Test.txt" prints the system information to a file; but when I use Execute("systeminfo >Test.txt") through Hollywood, the command is not executed, and I get the following message:

"Windows cannot find 'C:\Users\systeminfo'. Make sure you typed the name correctly, and then try again."

Is there some syntax that I can use to make it clear that I'm trying to execute a command, not find a file?
User avatar
Clyde
Posts: 349
Joined: Sun Feb 14, 2010 12:38 pm
Location: Dresden / Germany

[26 Oct 2011] Re: Executing a Command in Windows using Execute()

Post by Clyde »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Wed, 26 Oct 2011 23:10:23 +0200

Hi!

Two things come to my mind: 1. Is your file systeminfo located under C:\Users? If not, I guess you have to pass the complete path to the file. 2. I would suggest to give systeminfo a suitable file extension. What kind of programme is it? A binary one/exe? The call it systeminfo.exe. Or a .bat? Then go for systeminfo.bat. On Windows, much is ruled by the file extension. I assume this is your problem. Hollywood does not search for the file explictly, it just wants to execute it but then recognizes, that it cannot find it - thus the error message.

I hope, that helps!

Regards!
Currently using: Hollywood 9 with Windows IDE and Hollywood 9 with Visual Studio Code and hw4vsc
PEB
Posts: 569
Joined: Sun Feb 21, 2010 1:28 am

[26 Oct 2011] Re: Executing a Command in Windows using Execute()

Post by PEB »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Wed, 26 Oct 2011 14:22:02 -0700 (PDT)

systeminfo isn't a file; it's a command. (Try it in a Windows CLI.)
Yvan

[28 Oct 2011] Re: Executing a Command in Windows using Execute()

Post by Yvan »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Fri, 28 Oct 2011 11:03:13 +0100

Hello Rev.

It is a file. On my Windows 7 machine the path is:

c:\windows\system32\systeminfo.exe
PEB
Posts: 569
Joined: Sun Feb 21, 2010 1:28 am

[28 Oct 2011] Re: Re: Executing a Command in Windows using Execute()

Post by PEB »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Fri, 28 Oct 2011 06:48:32 -0700 (PDT)

So I'm still wondering if there is a way to execute a Windows CLI command using Execute() in Hollywood, such as: Execute("dir >Test.txt")
PEB
Posts: 569
Joined: Sun Feb 21, 2010 1:28 am

[28 Oct 2011] Re: Re: Executing a Command in Windows using Execute()

Post by PEB »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Fri, 28 Oct 2011 07:17:03 -0700 (PDT)

Also, Execute("c:\windows\system32\systeminfo.exe >Test.txt") does not produce the file "Test.txt" as it should.
User avatar
airsoftsoftwair
Posts: 5443
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

[28 Oct 2011] Re: Re: Executing a Command in Windows using Execute()

Post by airsoftsoftwair »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Fri, 28 Oct 2011 23:06:52 +0200
Also, Execute("c:\windows\system32\systeminfo.exe >Test.txt") does not produce the file "Test.txt" as it should.
Windows does this differently than AmigaOS. In fact, there are two types of Windows executables: Console programs and Windows programs. Redirecting output of a console program to a file is done by Windows' console handler. It's not part of the system as it's on AmigaOS. You could try to work around this limitation by creating a *.bat file which does the job and passing this *.bat file to Execute(), i.e. put the following line in a *.bat:

Code: Select all

c:\windows\system32\systeminfo.exe >Test.txt
And then run Execute("test.bat") from Hollywood. Should work because running a *.bat file will invoke the console handler.
PEB
Posts: 569
Joined: Sun Feb 21, 2010 1:28 am

[28 Oct 2011] Re: Re: Executing a Command in Windows using Execute()

Post by PEB »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Fri, 28 Oct 2011 16:54:59 -0700 (PDT)

Yep, that worked. Thanks! (I never would have thought to try that.)
User avatar
airsoftsoftwair
Posts: 5443
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

[29 Oct 2011] Re: Re: Executing a Command in Windows using Execute()

Post by airsoftsoftwair »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Sat, 29 Oct 2011 11:26:44 +0200
Yep, that worked. Thanks! (I never would have thought to try that.)
Good. Keep in mind though that systeminfo.exe is not installed on every Windows PC. I'm running the Home Edition of XP here and I don't have that command at all. According to Google it's only included with the Professional Edition of XP... only Microsoft knows why.
Locked