Page 1 of 2
Handle command prompt messages
Posted: Thu May 27, 2010 4:34 am
by alemrantareq
Hi everybody, I've made a script to handle the command prompt messages -
Code: Select all
on mouseUp
set the hideconsolewindows to true
get shell("ren c:\test myTest")
if the result is "The system cannot find the file specified." then
answer "Error"
else
answer "Renamed successfully!"
end if
end mouseUp
The problem is that it always answers "Renamed successfully!" whether the folder "test" exists in C: drive or not. I just can't understand what wrong I made. Someone pls, help me correcting this script. Thanks in advance..........

Re: Handle command prompt messages
Posted: Thu May 27, 2010 9:41 am
by Mark
alemrantareq,
Probably, there is a return character at the end of the returned string. Try
Code: Select all
if the result contains "The system cannot find the file specified." then
Best,
Mark
Re: Handle command prompt messages
Posted: Thu May 27, 2010 9:57 am
by alemrantareq
Thanks Mark for replying, but its not working......

Re: Handle command prompt messages
Posted: Thu May 27, 2010 10:00 am
by Mark
Sorry, alemrantareq, I forgot to add that you need to replace "the result" with "it". If that still doesn't work, then you need to post the complete output.
Best,
Mark
Re: Handle command prompt messages
Posted: Thu May 27, 2010 10:20 am
by alemrantareq
WOW ! it really works perfect ! Thanks a lot
Mark.........Cheers !!!

Re: Handle command prompt messages
Posted: Sat May 29, 2010 1:40 pm
by alemrantareq
Sometimes cmd seeks permission like [Y/N] where we need to press Y and Enter to complete the task. For example, for fixing drive error, we type "chkdsk [drivename:] /f" which sometimes ask [Y/N] type permission to dismount that drive. As we hide the console windows before working with command prompt, how can I handle that [Y/N] situation?
Re: Handle command prompt messages
Posted: Mon May 31, 2010 9:26 pm
by Janschenkel
In that case, you shouldn't use the shell function, but opt for a combination of the open process, read from process, write to process and close process commands. This will allow you to exchange data with a separate command-line process.
HTH,
Jan Schenkel.
Re: Handle command prompt messages
Posted: Tue Jun 01, 2010 3:34 am
by alemrantareq
Hi
Janschenkel, thanks for giving me the idea but I can't figure it out properly. For example, I wrote -
And then, it asks me to input the current label of the drive. I know the label of it but I just want to know how can I input the label without showing the command prompt window. Please, do me a fever giving a sample for it.
Re: Handle command prompt messages
Posted: Wed Jun 02, 2010 2:08 pm
by alemrantareq
I'm stuck with my project and can't continue until I get a sample of my last reply. Pls, someone help me.......pls.

Re: Handle command prompt messages
Posted: Sun Jun 06, 2010 8:11 pm
by alemrantareq
It has been a long time that no one could give me a sample. So my pals, I think I should reject my project, right?

Re: Handle command prompt messages
Posted: Sun Jun 06, 2010 8:24 pm
by Mark
alemrantareq,
What you want might be possible, but it takes me too much time to work it out. An alternative might be to write a VBScript. You could ask on the VBScript newgroup.
Best,
Mark
Re: Handle command prompt messages
Posted: Mon Jun 07, 2010 3:13 pm
by alemrantareq
Dear
Mark, your reply made me pleased ! I've made a deep search on VBScript, but nothing found fruitful. I thank you to work on it & I'm patient for your reply.........

Re: Handle command prompt messages
Posted: Mon Jun 07, 2010 3:22 pm
by Mark
Hi alemrantareq ,
As I wrote, you should not ask here. Ask on the VBScript newsgroup instead.
Best,
Mark
Re: Handle command prompt messages
Posted: Tue Jun 08, 2010 4:11 am
by alemrantareq
I've asked on the VBScript newsgroup and got a reply.
Click Here to see it.
As I've no knowledge on VBScript, please someone help me explaining the vbscript. I mean where I've to make changes and how, where I should input [Y/N] or [Enter] where the console windows prompts for [Y/N] or [Enter], so that I can hide the console windows, and how to apply it in rev.ent. Please...........
Re: Handle command prompt messages
Posted: Wed Jun 16, 2010 12:07 pm
by Mark
Hi alemrantareq,
Apparently, you can execute the command as one line:
echo [YourLabel]| convert [drivename]: /fs:ntfs
In Revolution, you can use the shell() function:
Code: Select all
get shell("echo [YourLabel]| convert [drivename]: /fs:ntfs")
Read Tom's messages to find out what to replace the strings in brackets with.
Best regards,
Mark