Jump to content

How to Send brackets to cmd prompt


Recommended Posts

Hello all,

I am extremely new to Autoit, so please excuse me if this is a very noobly question =)

This is what I am trying to do:

RunAs ("administrator", 0, "nothingtoseehere", 64, "cmd.exe")

WinWaitActive ("Administrator: C:\Windows\system32\cmd.exe")

Send ("taskkill /f /im nlnotes.exe")

Send ("{ENTER}")

Send ("taskkill /f /im notes2w.exe")

Send ("{ENTER}")

Send ("taskkill /f /im ntaskldr.exe")

Send ("{ENTER}")

WinClose ("IBM Lotus Notes")

Send ("cd c:\windows")

Send ("{ENTER}")

Send ("rmdir /s /q c:\windows\temp")

Send ("{ENTER}")

WinClose ("Administrator: C:\Windows\system32\cmd.exe")

Run ("cmd.exe")

WinWaitActive ("C:\Windows\system32\cmd.exe")

Send ("pause")

Send ("{ENTER}")

Send ("a")

Send (" cd %userprofile%\appdata\local")

Send ("{ENTER}")

Send (" rmdir /s /q %userprofile%\appdata\local\temp")

Send ("{ENTER}")

Send ("cd c:\lotus\notes\")

Send ("{ENTER}")

Send ("type notes.ini | find "[Notes]" >notes.txt") ------Everything works wonderfully until I get to here.

Send ("{ENTER}") --------I know its because i have Notes in brackets, and autoit thinks im trying to flag it.

Send ("type notes.ini | find "Directory=" >>notes.txt")

Send ("{ENTER}")

Send ("type notes.ini | find "DskMgrPckPath=" >>notes.txt") -- It also doesnt like my =, or my >>. Also, I think it has something to do with my double

Send ("{ENTER}") ------------------------- ----- quotation marks. I have quotations within a quotation. Im just trying to send commands to the command prompt

Send ("ren notes.ini notes.old.bak")

Send ("{ENTER}")

Send ("ren notes.txt notes.ini")

Send ("{ENTER}")

WinClose ("C:\Windows\system32\cmd.exe")

Run ("notes.exe")

If anyone can help, I would very much appreciate it!

Link to comment
Share on other sites

Brackets are fine. It's the double quotes.

Here are two ways to get around this.

Send ("type notes.ini | find ""[Notes]"" >notes.txt") ; Double-double
...
Send ('type notes.ini | find "DskMgrPckPath=" >>notes.txt') ; Single/double

Although, you'd probably be better off writing all this stuff to a batch file and calling that, or converting the logic to pure AutoIt functions.

[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Link to comment
Share on other sites

Brackets are fine. It's the double quotes.

Here are two ways to get around this.

Send ("type notes.ini | find ""[Notes]"" >notes.txt") ; Double-double
...
Send ('type notes.ini | find "DskMgrPckPath=" >>notes.txt') ; Single/double

Although, you'd probably be better off writing all this stuff to a batch file and calling that, or converting the logic to pure AutoIt functions.

Wow. Thank you so much. Something so little makes such a huge difference. I have been at this all morning. Really appreciate the quick reply.

The only reason why I dont want to have this call a batch file is because i want it all contained in one file. I want to send this out as an exe for all of our users who are having this certain issue with their lotus notes crashing. Just a one stop shop to click it and not have to worry about them having network access or multiple files. What do you mean by converting the logic to pure autoit functions?

Link to comment
Share on other sites

Although, you'd probably be better off writing all this stuff to a batch file and calling that, or converting the logic to pure AutoIt functions.

I was thinking the same thing whey i read the title of this thread. I use to dabble with batch files, they are simple to write and you can call them with autoit. Here is a link that gives you what you need to write those cmd calls: http://www.computerhope.com/batch.htm#02

Link to comment
Share on other sites

There are built in INI functions, ProcessClose etc? Whats wrong with using the built in AutoIt functions? And I find writing to a batch file pretty silly... ^_^

Link to comment
Share on other sites

The only reason why I dont want to have this call a batch file is because i want it all contained in one file. I want to send this out as an exe for all of our users who are having this certain issue with their lotus notes crashing. Just a one stop shop to click it and not have to worry about them having network access or multiple files.

You can use FileWrite/FileWriteLine/FileInstall to generate the batch file, then run it and delete it. In this sense, you still only need to distribute a single EXE.

What do you mean by converting the logic to pure autoit functions?

You can accomplish everything using native AutoIt functions, if you learn what to use and how.

taskkill ~ ProcessClose

rmdir ~ DirRemove

type ~ FileRead

find ~ StringInStr

> ~ FileWrite

[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Link to comment
Share on other sites

And I find writing to a batch file pretty silly... ^_^

heheh I've always been the type of person to get it done how it know to. As an alternative I think it's fine. Although I am glad the original poster now has a solution using Autoit's language ;) Who knows, maybe a year from now someone will read this thread looking for an answer and a batch file subroutine would work well for them *shrug*

Link to comment
Share on other sites

You can use FileWrite/FileWriteLine/FileInstall to generate the batch file, then run it and delete it. In this sense, you still only need to distribute a single EXE.

You can accomplish everything using native AutoIt functions, if you learn what to use and how.

taskkill ~ ProcessClose

rmdir ~ DirRemove

type ~ FileRead

find ~ StringInStr

> ~ FileWrite

holy crap. Autoit just became THAT much more amazing. I am really taking the long route here huh? haha So where can I go to see a list of native autoit commands, and the comparable batch commands? Thanks again Skruge.

Link to comment
Share on other sites

holy crap. Autoit just became THAT much more amazing. I am really taking the long route here huh? haha So where can I go to see a list of native autoit commands, and the comparable batch commands? Thanks again Skruge.

The helpfile is your friend.
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...