Sign in to follow this  
Followers 0
friends

How To Use @comspec ?

7 posts in this topic

well... i know there is a command for @COMSPEC,

what is the purpose of this and how to use it ?

PS : Please don't ask me to look at the HELP FILE, cos the HELP FILE

is not actually shown out the actual usage of it (personally think so).

please... i need to understand this.... thank you very much

Share this post


Link to post
Share on other sites



It returns a value that you can depend on to launch a DOS session. This value is different for different operating systems, and could even be different depending on custom pathnames.

The bottom line is that it makes life easier for you as a scripter when you want to launch a DOS command or whatever.

HTH

Share this post


Link to post
Share on other sites

Of course it is DOS only in W9x. In WinXP/2000 it is the command line console.

Share this post


Link to post
Share on other sites

...but the most useful use of @Comspec is using it with Start for starting any kind of file with its related application.

E.G. (W2000/XP if you still use W9x, remove the "" after Start)

$StartMe = myfile.txt

RunWait(@Comspec ' /c start "" "' & $StartMe & '"','',@SW_hide)

$StartMe could be any file, a link (e.g. http:\\www.anipike.com ) or even a maillink ( e.g. mailto:ezzetabi@katamail.com ).

Cool, isnt it?

Share this post


Link to post
Share on other sites

thanks for the information... wow !

mind to give more example ?

if possible... workable example.... very thanks !

Share this post


Link to post
Share on other sites

if possible... workable example.... very thanks !

<{POST_SNAPBACK}>

Here's an example. It gives you a folder selection prompt, and will then use the command interperter (IE: @ComSpec) to output the "dir" command for that folder, and output the output from that command to a file in the temp folder. It will then let you view that output in a notepad window. Upon closing the notepad window, it will clean up the temp file it created.

$my_computer = "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}"
$folder = FileSelectFolder("Pick a folder", $my_computer)
If @error Then
  MsgBox(0, "Quitting", "You didn't pick a folder.  Now quitting")
  Exit
EndIf
Run(@ComSpec & " /c dir " & $folder & " > " & @TempDir & "\dirlist.txt", @SW_HIDE)
MsgBox(0, "Complete", "The dir command for that folder has been" & @LF & _
 "sent to a file. Click OK to open that file in a notepad window." & @LF &_
 "When you close the file, the temporary file will be removed.")
Run('notepad "' & @TempDir & '\dirlist.txt"')
WinWait("dirlist.txt - Notepad")
Do
  Sleep(50)
Until NOT WinExists("dirlist.txt - Notepad")
For $i = 0 To 20
  If FileDelete(@TempDir & "\dirlist.txt") Then Exit
  Sleep(1000)
Next
MsgBox(16, "Error", "Sorry, unable to delete the temp file.")

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Share this post


Link to post
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
Sign in to follow this  
Followers 0