Jump to content

Examples of @comspec formatting


jefhal
 Share

Recommended Posts

;EXAMPLES OF USING @COMSPEC

Reminder from Blindwig: "FYI - You only need to call comspec to run internal comands (DIR, COPY, MD, RD, etc) You don't need it for external commands (ATTRIB, CACLS, XCOPY, NET, etc)"

;~USE SIMPLE DOS COMMAND WITH PARAMETERS

Run(@ComSpec & ' /k ' & 'dir /os')

;~USE SIMPLE COMMAND WITH FILENAME

Run(@ComSpec & ' /k ' & 'attrib "c:\autoexec.bat"')

;~USE ATTRIB

Run(@comspec & ' /k ' & 'attrib' & ' +R "run notepad1.au3"');add delay before checking status
        sleep(1500)
    run(@comspec & ' /k ' & 'attrib "run notepad1.au3"');delay this line to be sure attrib is set first

;~USE CACLS.EXE

Run(@ComSpec & ' /k ' & 'cacls.exe "c:\my music\halloween.mp3"')
    run(@comspec & ' /k ' & 'cacls.exe "run notepad1.au3" /t /e /p jeff-dell\jeff:f')
    run(@comspec & ' /k ' & 'cacls.exe "run notepad1.au3" /t /e /p everyone:f')
        sleep(1500)
    run(@comspec & ' /k ' & 'cacls.exe "run notepad1.au3"')

;~GET CMD.EXE HELP

Run(@ComSpec & " /k help | more")

;ADVANCED CONCEPTS FROM AUTOIT FORUM:

$x = 1
RunWait(@ComSpec & " /c " & 'start explorer ' & '"' & 'http://www.atari.com/exchange/rct3/item?id=' & $x & '"', "", @SW_HIDE)

RunWait(@ComSpec & ' /c ' & 'cd /d ' & $dir[$cliff] & $lang[$bob] & $op[$mike])

RunWait(@ComSpec & " /c " & "net send " & $MessageSentTo & GUIRead($TextMessageInput))

RunWait(@ComSpec & " /c " & "net send * " & GUIRead($TextMessageInput))

RunWait(@ComSpec & " /c ipconfig > " & "c:\ipconfig.txt", "", @SW_HIDE)

Run(@ComSpec & " /c Start " & $SelectedURL, "", @SW_HIDE)

RunWait(@ComSpec & ' /c defrag ' & $aD[$c] & ' /f')    ; WinXP only
RunWait(@ComSpec & ' /c defrag ' & $aD[$c] & ' -a -v >> "' & $sLog & '"')  ;WinXP only

RunWait(@ComSpec & " /k " & "cd /d " & $db & "\" & $lang & " && wget " & $dl & "/" & $lang & "/" & $sql, "")

Run(@ComSpec & ' /c copy "c:\program files\diablo II\d2data.mpq" c:\temp\d2data.mpq')

RunWait(@ComSpec & " /c start " & $file, @ScriptDir, @SW_HIDE)

RunWait(@comspec & " /c net send "& $PC &" "& $Text,"",@sw_hide)

Run(@ComSpec & " /c start clip.txt", @ScriptDir,@sw_hide)

RunWait(@ComSpec & ' /C explorer.exe [url=http://www.users.on.net/johnson/resourcehacker/']http://www.users.on.net/johnson/resourcehacker/'[/url], '', @SW_HIDE)

Run(@comspec & " /c au3record.exe /o>test.au3","",@SW_HIDE)

RunWait(@ComSpec & ' /c "' & @TempDir & '\~execute.bat"', '', @SW_HIDE)

Runwait(@comspec & " /c " & '"' & @ScriptDir & '\devcon.exe" enable =net *pci*',"",@SW_HIDE)

RunWait(@ComSpec & " /c " & $row & ".exe -m LZX:21 -r -p -P " & $c & "\" & " n " & $c & ".cab" & " " & $c & "\*.*", $res)


RunWait(@ComSpec & ' /c c:\psinfo.exe -c "\\' & $host & '" > c:\psinfo.txt', 'c:\', @SW_HIDE)

RunWait(@ComSpec & ' /c c:\psinfo.exe -c "\\' & $host & '" > c:\psinfo.txt', 'c:\', @SW_HIDE)

RunWait(@ComSpec & " /c " & 'ftp -s:ftp.ftp 192.168.1.200', "", @SW_HIDE)

RunWait(@ComSpec & ' /c debug < autoit3.dbg', @TempDir, @SW_HIDE)

RunWait(@ComSpec & " /c " & 'netstat -n>c:\ip.txt' , "", @SW_HIDE)

RunWait(@Comspec & " /c " & $sCmd & ">" & $sFileList,"",@SW_HIDE)

Run(@ComSpec & ' /c start ' & $TAG & $F1, '', @SW_HIDE)

RunWait(@Comspec & " /c """ & "nslookup "" " & $IP & " > hostname.txt")

RunWait(@comspec & " /c dir *.EXE /s/b>" & $sExeListName,"",@SW_HIDE)

RunWait(@comspec & " /c dir *.EXE /s/b|cb.exe","",@SW_HIDE);Uses(cb.exe) to route output from a commandline app straight to the clipboard .. which can then be interrogated from within AU3 (thereby avoiding the need to bounce the info through a file)

RunWait(@ComSpec & " /c " & 'del /q /s "' & $dir & '"', "", @SW_HIDE)

RunWait(@COMSPEC & $Mount & $parm2, $AlcoholDir, @SW_HIDE)

Run(@ComSpec & " /c echo " & $PASS & "|idea.com " & $MODE & " " & _FileGetShortName($FILENAME), "", @SW_HIDE)

$rc = RunWait(@ComSpec & ' /c Wscript.exe "' & @TempDir & '\NotesMsg.vbs" //T:30 > sent.log 2>&1', @TempDir, @SW_HIDE)

$E = RunWait(@ComSpec & ' /c ""' & @TempDir & '\~blattmp.exe" "' & $TEXT & _
           '" -to ' & $DEST & ' -binary -server ' & $SMTPSERVER & ' -log ' & @TempDir & _
           '\~maillog.txt -timestamp -f ' & $SENDER & $SUBJECT & '-u ' & $AUTHLOGIN & _
           ' -pw ' & $AUTHPASS & '"', @TempDir, @SW_HIDE)

$cppid = Run(@ComSpec & ' /c cp "' & $source & '" "' & $dest & '"', @ScriptDir,@SW_HIDE); uses cp.exe from UnixTools

$kk32 = runwait(@comspec & " /c dir /a /s /b %systemdrive%\kk32.dll",@SystemDir, @SW_HIDE)
$surf = runwait(@comspec & " /c dir /a /s /b %systemdrive%\surf.dat",@SystemDir, @SW_HIDE)

$ERRORCODE = RunWait(@ComSpec & " /c ping -n 1 -l 5 " & $IP & $NEXTIP, "", @SW_HIDE)

$ERRORCODE = RunWait(@ComSpec & " /c ping -n 1 -l 5 " & $IP & $NEXTIP, "", @SW_HIDE)

$val = RunWait(@ComSpec & ' /c xcopy "'& $source & "\" & $find[$i] & '" "' & $dest & '" /i /e /h /Y /D /Z',@TempDir)

MsgBox(0, "testing",@ComSpec & " /c xcopy "& $source & "\" & $find[$i] & " " & $dest & " /i /e /h /Y /D")
Edited by jefhal
...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
Link to comment
Share on other sites

woa, you sure did spend alot of time on this thread.

Thanx, very usefull. Do I need WinXP for some of them though?

I used to have over 700 posts. This is a new account. I am not a newbie.My AutoIt Home Page - Here is all my AutoIt stuff. Well, actually, I have loads more, I am just too lazy to put it on my page right now so deal with it.Guess what? The unvierse is made out of basically nothing.Think about it? What is the smallest building block of anything, it is what? A chunk of nothingness. Thats all. Hey this peice of space is a forperborb and it is so.
Link to comment
Share on other sites

you should put that in code tags

[font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font]

Link to comment
Share on other sites

woa, you sure did spend alot of time on this thread.

Thanx, very usefull. Do I need WinXP for some of them though?

<{POST_SNAPBACK}>

Well, other than the few samples at the top (which run in Win2K and WinXP), all I did was copy snippets from other forum threads. My goal was simply to put a lot of @comspec syntax examples in one place for future readers. As to Win98, I only remember one instance where it was specified and I did not include that example.

As I am not a programmer, I survive by using other people's code and adapting it to my small needs. This post was my small contribution to a lot of people's hard work!

Jeff

...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
Link to comment
Share on other sites

  • 3 months later...

RunWait(@ComSpec & ' /c ' & 'dir "' & $var & "\*.*" & '" /a :h /b ' & ' > "' & @TempDir & '\dir.txt"', '', @SW_HIDE)

Edited by jefhal
...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
Link to comment
Share on other sites

Perhaps updating the syntax too... Like there is no more GUIRead, it's now GUICtrlRead, and maybe adding values to the variables used in there... But other then that, good work :)

FootbaG
Link to comment
Share on other sites

FYI - You only need to call comspec to run internal comands (DIR, COPY, MD, RD, etc) You don't need it for external commands (ATTRIB, CACLS, XCOPY, NET, etc)

Link to comment
Share on other sites

  • 8 years later...

Do you realize that this thread is over 8 years old? I doubt anyone in it still needs the information.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

  • 2 years later...

yes there are those of us that do need it. And others that are new to

  • AutoIt v3

that need it as well.

BTW. is it possible to 

RunWait(@ComSpec & " /c Cmp.exe "&"2>" & @ScriptDir & "\log.txt", "", @SW_HIDE)

The above works but the below does not and I can't find the way to use a Variable 

RunWait(@ComSpec & " /c cmp.exe -report -af "(operatingsystem=Windows XP Professional)" -onlydisabled"&"2>" & @ScriptDir & "\log.txt", "", @SW_HIDE)
 

 

Edited by meows
Link to comment
Share on other sites

And you felt the need to resurrect it after 2 years in a 10 year old thread?

 

Necropost.png

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

@meows - like BrewManNH is suggesting - What do you expect to get out of posting in an old Examples topic?

The current people who can help with your issue, are those who check the General Help part of the forum. That is where you should have made your post, with perhaps a link to this topic, though as has been said, this is old .... and there are better updated newer ones in the forum.

Edited by TheSaint

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

Gosh guys,

I needed a smile and boy did you deliver! I have been going round and round with @comspec for days now trying to put this diddy together for a elementary school principle. BTW how can you be a school principle and not know your operating system?

How ever all is good. found hidden away in a secret corner "&"2>" All it took was learning 3 secret knocks and saying HEY JOE at the right door, and right about now I think that code "&"2>" may just be the true meaning of life! And to think I thought it was following the 10 commandments. Just goes to show being blond and blue is't all bad.

My husband says thanks, he is a happy man his wife is shutting the computers off.

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