Jump to content

Help with cmd through autoit


Recommended Posts

Hi guys,

Sorry if I am not very clear, but I was wondering whether I could use cmd directly through AutoIt. To run my batch file as admin, I would use the following code:

Run("cmd.exe")
Send("elevate mybatfile.bat{ENTER}")

This would lead to my batch file run as admin, and I could do things without much of a problem. But the problem here lies in that this script is not bulletproof. If i manage to somehow distract the computer, say ctrl+alt+delete, even if i do lock keys, the script will be disrupted. I want to run the cmd command directly from autoit. I am not exactly good at using @comspec either, if it can somehow be used here. So can someone give me help on how i should use the elevate mybatfile.bat thing directly from autoit?

Link to post
Share on other sites

I took a look at that. Not too helpful. I tried all variations that i could imagine of the Run command with @COMSPEC. All of them just lead to the hourglass for less than half a second and nothing happens. It doesn't seem to work.

Link to post
Share on other sites

I took a look at that. Not too helpful. I tried all variations that i could imagine of the Run command with @COMSPEC. All of them just lead to the hourglass for less than half a second and nothing happens. It doesn't seem to work.

Try this and post back what you see:

$CommandName = "mybatfile.bat"
Run(@ComSpec & " /k " & $CommandName, "", @SW_SHOW) ; don't forget " " before "/k"
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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...