Jump to content
Einstein197

execute cmd commands

Recommended Posts

Einstein197

In command prompt I use "netsh wlan start hostednetwork"  how can I do that in autoit

Share this post


Link to post
Share on other sites
Melba23

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


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites
Einstein197

Cool that it

 

Share this post


Link to post
Share on other sites
fawder

how can this be ran as a local admin?

Share this post


Link to post
Share on other sites
TheSaint
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

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

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

Share this post


Link to post
Share on other sites
fawder

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

Share this post


Link to post
Share on other sites
Subz
#RequireAdmin
Local $sServiceName = "Service Name"
RunWait(@ComSpec & ' /k net stop "' & $sServiceName & '"')

 

Edited by Subz
Fixed Syntax error missed single quote at end of line.

Share this post


Link to post
Share on other sites
fawder
29 minutes ago, Subz said:
#RequireAdmin
Local $sServiceName = "Service Name"
RunWait(@ComSpec & ' /k net stop "' & $sServiceName & '")

 

Hi @Subz when I test run, I get-

error: syntax error (illegal character) and a yellow dot to the left of the last line.

thanks!!

Share this post


Link to post
Share on other sites
Earthshine

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


My resources are limited. You must ask the right questions

 

Share this post


Link to post
Share on other sites
fawder
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...

Share this post


Link to post
Share on other sites
Earthshine

you can also use SC to turn on or off servers or config them. built into windows.

 

Capture.PNG


My resources are limited. You must ask the right questions

 

Share this post


Link to post
Share on other sites
fawder
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.

Share this post


Link to post
Share on other sites
Earthshine

SC start ServiceName

 

can't get any easier, no quotes


My resources are limited. You must ask the right questions

 

Share this post


Link to post
Share on other sites
fawder
Just now, Earthshine said:

SC start ServiceName

 

can't get any easier, no quotes

i will try this. thanks Earthshine!

Share this post


Link to post
Share on other sites
Earthshine

you may still need Admin, but others on this site know what your script will need to give it admin power, I am sure


My resources are limited. You must ask the right questions

 

Share this post


Link to post
Share on other sites
TheSaint
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.

  • Like 1

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

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

Share this post


Link to post
Share on other sites
Einstein197
On 3/11/2018 at 5:18 AM, Subz said:

 

RunWait(@ComSpec & " /c netsh wlan start hostednetwork", "", @SW_HIDE) ;~ Runs command hidden

 

Thanks it worked perfectly

Share this post


Link to post
Share on other sites
fawder
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)

  • Thanks 1

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

×