mIRC Home    About    Download    Register    News    Help

Print Thread
Page 1 of 2 1 2
$run identifier #34378 06/07/03 09:39 AM
Joined: Jul 2003
Posts: 1
A
antisocial Offline OP
Mostly harmless
OP Offline
Mostly harmless
A
Joined: Jul 2003
Posts: 1
I think it would be quite useful to have a $run identifier, which would return $true/$false depending on if mirc can /run a file or url.

For example:

if ($run(notepad)) { run notepad }

Rather than using $isfile or $exists (which wouldn't work on 'notepad' anyway) - this identifier would only see if $1 could be /run

I hope my point is being made and maybe someone will agree with me smile

Thanks for the word,

antisocial

Re: $run identifier #34379 06/07/03 04:22 PM
Joined: Dec 2002
Posts: 2,809
C
codemastr Offline
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 2,809
Well how does mIRC determine if it can be run?

Re: $run identifier #34380 06/07/03 04:39 PM
Joined: May 2003
Posts: 2,265
P
pheonix Offline
Hoopy frood
Offline
Hoopy frood
P
Joined: May 2003
Posts: 2,265
if a file is locked for example. it cannot be run, mirc could then say blah is locked and cannot be run.


new username: tidy_trax
Re: $run identifier #34381 06/07/03 04:44 PM
Joined: Dec 2002
Posts: 2,985
Watchdog Offline
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 2,985
Quite right but that isn't the issue. mIRC can't know of the opposite being true until the application is running so you can't get a result until the programme starts.

Look at it in this light: You pick up the phone and ring me - you don't know I am going to answer the call until I actually pick up the handset.

Re: $run identifier #34382 06/07/03 04:56 PM
Joined: May 2003
Posts: 2,265
P
pheonix Offline
Hoopy frood
Offline
Hoopy frood
P
Joined: May 2003
Posts: 2,265
maybe give it a timer then. say like, if its not open in 5 seconds, return $false


new username: tidy_trax
Re: $run identifier #34383 06/07/03 04:59 PM
Joined: Dec 2002
Posts: 2,962
S
starbucks_mafia Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
But then that means $run has to actually run the command to see if it works, which is almost cetainly not what the user wanted.


Spelling mistakes, grammatical errors, and stupid comments are intentional.
Re: $run identifier #34384 06/07/03 05:18 PM
Joined: May 2003
Posts: 2,265
P
pheonix Offline
Hoopy frood
Offline
Hoopy frood
P
Joined: May 2003
Posts: 2,265
try to access the file, if it starts to load, then cancel the opening of it and return $true


new username: tidy_trax
Re: $run identifier #34385 06/07/03 05:34 PM
Joined: Dec 2002
Posts: 2,985
Watchdog Offline
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 2,985
What would this function actually be useful for? What did you want to do with it?

Re: $run identifier #34386 06/07/03 05:49 PM
Joined: Dec 2002
Posts: 2,809
C
codemastr Offline
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 2,809
Thats not even what I meant, what happens if I specify a file that isn't executable?

$run(README) for example

How is mIRC to know that that file can't be run?

Re: $run identifier #34387 06/07/03 05:51 PM
Joined: May 2003
Posts: 2,265
P
pheonix Offline
Hoopy frood
Offline
Hoopy frood
P
Joined: May 2003
Posts: 2,265
if it doesnt open ;s


new username: tidy_trax
Re: $run identifier #34388 06/07/03 06:06 PM
Joined: Dec 2002
Posts: 2,809
C
codemastr Offline
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 2,809
It will open, it's a file, any file can be opened. If it couldn't be opened, then there would be no way to view a README in notepad for example. There is no IsFileExecutable() function in Windows.

Re: $run identifier *DELETED* #34389 06/07/03 06:09 PM
Joined: May 2003
Posts: 2,265
P
pheonix Offline
Hoopy frood
Offline
Hoopy frood
P
Joined: May 2003
Posts: 2,265
Post deleted by pheonix


new username: tidy_trax
Re: $run identifier #34390 06/07/03 06:19 PM
Joined: Dec 2002
Posts: 2,809
C
codemastr Offline
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 2,809
Umm apparently you have no idea what a locked file is, it has nothing to do with a password. A locked file is when you get the "can not open, this file is in use by another application" error.

From Microsoft:
"The LockFile function locks a region in an open file. Locking a region prevents other processes from accessing the region."

I don't see any mention of a password there, do you?

And that doesn't have anything to do with what I said:

codemastr: phoenix, why is the sky blue?
phoenix: some cars are blue.

You didn't address anything I stated, you simply wrote some gibberish.

Re: $run identifier *DELETED* #34391 06/07/03 06:25 PM
Joined: May 2003
Posts: 2,265
P
pheonix Offline
Hoopy frood
Offline
Hoopy frood
P
Joined: May 2003
Posts: 2,265
Post deleted by pheonix


new username: tidy_trax
Re: $run identifier #34392 06/07/03 06:27 PM
Joined: Apr 2003
Posts: 210
S
saxon Offline
Fjord artisan
Offline
Fjord artisan
S
Joined: Apr 2003
Posts: 210
That isn't what the poster wanted though. I think he wanted an alternative to $isfile and $exists. He gave the example of 'notepad'. If notepad doesn't exist on the users system they will get an error message:

* /run: unable to open 'notepad'

I believe this suggestion is aimed at avoiding error messages like that.

Ofcourse there is no API way of doing this. However, with a little thought, It is possible that mIRC could check the registry and see if 'notepad' is registered, in the case of no filepath being specified. And then return $true or $false.

It's also possible that mIRC could perform the operation of $isfile internally and return $true or $false, when a filepath is specified.

There may also be a way to determine if a user has access to that file under NT, and return $true or $false.

--
A more general method of handling all mIRC error messages would be preferable to me though (ON MERROR).

Re: $run identifier #34393 06/07/03 06:42 PM
Joined: Dec 2002
Posts: 2,809
C
codemastr Offline
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 2,809
Well if that doesn't make sense, yell at Microsoft, they are the ones who decided a "locked" file has nothing to do with a password. A file that needs a password to be opened (depending on some conditions) is either "password protected" or "encrypted" NOT locked. It's not my fault you don't understand FileSystem terminology.

Re: $run identifier *DELETED* #34394 06/07/03 06:51 PM
Joined: May 2003
Posts: 2,265
P
pheonix Offline
Hoopy frood
Offline
Hoopy frood
P
Joined: May 2003
Posts: 2,265
Post deleted by pheonix


new username: tidy_trax
Re: $run identifier #34395 06/07/03 06:53 PM
Joined: Dec 2002
Posts: 2,809
C
codemastr Offline
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 2,809
*sigh* whatever, you're wrong, you just don't want to admit it.

Re: $run identifier *DELETED* #34396 06/07/03 06:57 PM
Joined: May 2003
Posts: 2,265
P
pheonix Offline
Hoopy frood
Offline
Hoopy frood
P
Joined: May 2003
Posts: 2,265
Post deleted by pheonix


new username: tidy_trax
Re: $run identifier #34397 06/07/03 06:59 PM
Joined: Dec 2002
Posts: 2,809
C
codemastr Offline
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 2,809
But regardless, thats not what the original poster, or I were talking about. I said what happens if you want to determine if a file such as "README" is run-able? How can you determine if it is? The answer is, you really can't.

Re: $run identifier #34398 06/07/03 07:02 PM
Joined: May 2003
Posts: 2,265
P
pheonix Offline
Hoopy frood
Offline
Hoopy frood
P
Joined: May 2003
Posts: 2,265
i know, i admit it im wrong, and i shouldnt of posted in the 1st place.


new username: tidy_trax
Re: $run identifier #34399 07/07/03 07:33 AM
Joined: Feb 2003
Posts: 2,652
Raccoon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,652
Actually, I agree with saxon and there are ways to determine if /run can execute a file before it actually executes the file with ShellExecute.

First you'd check the system PATH to see if the file can be found ($ispath would be cool). If a file is located then trace the file extension through the registry to see if it's associated with an application or not (I believe an API exists for this even). Then you would test if the file is locked by the system by attempting to OPEN the file (doesn't have to physically read it, just requests permission to access it). If the OPEN fails, then /run is certain to fail aswell.

Granted, it would be impossible to cover all possible errors... eg: WinZip Error "File Appears Corrupt", could not possibly be anticipated... but the file still successfully /ran, and that's all that $run needs to do.

- Raccoon


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
Re: $run identifier #34400 07/07/03 03:12 PM
Joined: Dec 2002
Posts: 2,809
C
codemastr Offline
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 2,809
Association does not imply execution. For example, I have an association setup for .a23 files, however all the association does is make it so an icon is displayed for a23 files, if I click the file I get the standard "select a program" dialog box. File associations do not determine whether a file can be executed. And opening a file doesn't test a lock. I can lock bytes 23 through 29. Opening it will succeed, however when I try to read bytes 23 through 29 that will fail.

Re: $run identifier #34401 07/07/03 03:19 PM
Joined: Feb 2003
Posts: 2,652
Raccoon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,652
Files which are only associated for an icon don't have a 'command' folder with a value pointing to an application or reference. This is an obvious distinction that would be looked for.

files that are locked surely have some way to test for this regardless of what parts are locked.

- Raccoon


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
Re: $run identifier #34402 11/07/03 04:28 PM
Joined: Jun 2003
Posts: 195
N
Narusegawa_Naru Offline
Vogon poet
Offline
Vogon poet
N
Joined: Jun 2003
Posts: 195
From MSDN

GetBinaryType

The GetBinaryType function determines whether a file is executable, and if so, what type of executable file it is. That last property determines which subsystem an executable file runs under

BOOL GetBinaryType(
LPCTSTR lpApplicationName,
LPDWORD lpBinaryType
);

Wouldnt this be exactly what you want the $run identifier to do?


Have Fun smile
Re: $run identifier #34403 12/07/03 01:25 AM
Joined: Feb 2003
Posts: 2,652
Raccoon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,652
Yep. grin
And any other "if file cannot be accessed" checks that might be possible.


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
Page 1 of 2 1 2