Jump to content

execute cmd commands


Recommended Posts

  • Moderators

Einstein197,

Welcome to the AutoIt forums.

But in future, please no not resurrect old threads with only a passing relevance to your question. Just start a new thread as I have now done for you.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

2 hours ago, fawder said:

how can this be ran as a local admin?

Depends.

If you don't mind some interaction, you could just place #RequireAdmin at the top of your script.

But if you want to run with preset permissions, automation, then check out the RunAs or RunAsWait commands.

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

RunAs("username", "hostname", "password", 0, "")
$CMD = 'net stop "service name has spaces"'
RunWait('"' & @ComSpec & '" /k ' & $CMD, @SystemDir)

 

I get this in the command window:

System error 5 has occurred.

Access is denied.


C:\Windows\SysWOW64>

@TheSaint i was reading old posts and saw that you had a bunch of samples out there, but was not able to see/download any of them.

appreciate your help!!

Link to comment
Share on other sites

4 minutes ago, Earthshine said:

you know you can try to figure out what the syntax error is. you are supposed to learn, not just take other people's code and run

Thanks Earthshine - sorry i am not good at this stuff. been searching forums for the past week for this and how-to guides...

Link to comment
Share on other sites

2 minutes ago, gillesg said:

A single quote is missing

Thanks @gillesg getting an error:

System error 5 has occurred.

Access is denied.


C:\Users\username\Downloads\Auto IT\>

--

#RequireAdmin - does this mean I need to be an administrator to run this? if so, this will not work.

--

Context:

End users have an application that sometimes requires the service to be restarted(stopped/started)

They do not have admin rights to the computer. 

I'd like to create an executable that does this for them without me having to enter in the admin credentials at a prompt.

--

i appreciate everyone's ideas.

Link to comment
Share on other sites

16 minutes ago, fawder said:

#RequireAdmin - does this mean I need to be an administrator to run this? if so, this will not work.

So don't use it, just replace RunWait with RunAsWait. Look it up in the Help file for specific information about all the parameters.

Example

Local $sServiceName = "Service Name"
RunAsWait("your username", "your domain", "your password", logon_flag, @ComSpec & ' /k net stop "' & $sServiceName & '"', "workingdir" [, show_flag [, opt_flag]]] )

Obviously you need to enter all the other required values (username, password, etc), use appropriate flags, specify the working directory maybe.

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

14 hours ago, TheSaint said:

So don't use it, just replace RunWait with RunAsWait. Look it up in the Help file for specific information about all the parameters.

Example

Local $sServiceName = "Service Name"
RunAsWait("your username", "your domain", "your password", logon_flag, @ComSpec & ' /k net stop "' & $sServiceName & '"', "workingdir" [, show_flag [, opt_flag]]] )

Obviously you need to enter all the other required values (username, password, etc), use appropriate flags, specify the working directory maybe.

got it to run. thanks a bunch all!!

RunAsWait($sUserName, $sDomain, $sPassword, 0, @ComSpec & ' /k net stop "' & $sServiceName)

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