morg Posted August 22, 2011 Share Posted August 22, 2011 I am trying to get SC.exe to work in autoit but I am having issues with the password in the autoit script. If I run the command in the windows command prompt it works fine but not with the autoit script. I figure I must have something incorrect in my syntax however I don't seem to be able to figure out what that is. I am wondering if there is a special character Autoit doesn't like. The sc.exe command works like this sc.exe config "Service Name" obj= "DOMAIN\User" password= "password" on windows fine so I know I have the syntax correct there. The autoit script runs but the password isn't correct because the servie won't start when I use this in autoit. $pas = "%pass{}%$$@#(" $Use = "Domain\Username" RunWait(@ComSpec & " /c " & " net Stop ServiceName", "", @SW_HIDE) RunWait(@ComSpec & " /c " & " sc config ServiceName obj= " & $Use & " password= " & $pas & "", "", @SW_HIDE) RunWait(@ComSpec & " /c " & " net start ServiceName", "", @SW_HIDE) Link to comment Share on other sites More sharing options...
BrewManNH Posted August 22, 2011 Share Posted August 22, 2011 Have you tried using RunAs instead? 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 GudeHow 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 More sharing options...
Developers Jos Posted August 22, 2011 Developers Share Posted August 22, 2011 (edited) The commandline you type in CMD, does that contain the double quotes around any of the parameter? If so, they are missing in your runwait statements. use /k to debug your commandline statements. Edited August 22, 2011 by Jos Tripredacus 1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
morg Posted August 22, 2011 Author Share Posted August 22, 2011 The commandline you type in CMD, does that contain the double quotes around any of the parameter?If so, they are missing in your runwait statements.use /k to debug your commandline statements.Yes in the command line in windows I use double quotes around service, user and password. I am missing that for the serice name and I will add that in. As for /k switch how do I incorporate that into autoit to debug, I am not fimilar with that? Link to comment Share on other sites More sharing options...
morg Posted August 22, 2011 Author Share Posted August 22, 2011 Have you tried using RunAs instead?I don't need to the runas because I am running the script with credentials that enable me to change the logon user name and password. When I tested from the command prompt I was logged in the server with rights to change the username and password on the server and it worked fine but when I tried to change it using the auotit script it didn't work. Thanks for the reply I apprciate it.. Link to comment Share on other sites More sharing options...
Developers Jos Posted August 22, 2011 Developers Share Posted August 22, 2011 For debugging use this format: RunWait(@ComSpec & ' /k net Stop "ServiceName"', "") SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
morg Posted August 23, 2011 Author Share Posted August 23, 2011 For debugging use this format: RunWait(@ComSpec & ' /k net Stop "ServiceName"', "") I tried the above to debug using the correct service name worked great! When I tried RunWait below to change the user the message I got back was successful but my script still will not put the password in correct, I am totally stumped. $aPas = "password" $aUse = "Domain\UserName" RunWait(@ComSpec & ' /k sc config "ServiceName" obj= ' & $aUse & ' password= ' & $aPas & '', "", @SW_SHOW) Link to comment Share on other sites More sharing options...
Developers Jos Posted August 23, 2011 Developers Share Posted August 23, 2011 You do not have double quotes around the userid and password yet. Could that be it? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
morg Posted August 23, 2011 Author Share Posted August 23, 2011 You do not have double quotes around the userid and password yet. Could that be it?Ok do you mean where I am declaring them in the variable? If so how do I add the double quotes? Link to comment Share on other sites More sharing options...
smartee Posted August 24, 2011 Share Posted August 24, 2011 ..If so how do I add the double quotes?Umm, here are some links to get you familiar with using quotes in strings. FAQ: How can I use single or double quotes in strings? Link to comment Share on other sites More sharing options...
buscador1980 Posted August 6, 2013 Share Posted August 6, 2013 (edited) RunWait(@ComSpec & " /c " & " sc config ServiceName obj= " & $Use & " password= " & $pas & "", "", @SW_HIDE) this is you anser :& @CRLF & RunWait(@ComSpec & " /c sc config ServiceName obj= " & $Use & @CRLF & " password= " & $pas , "", @SW_HIDE) Edited August 6, 2013 by buscador1980 Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted August 6, 2013 Moderators Share Posted August 6, 2013 This thread is over two years old, and the OP has not been active in all that time, so I doubt your post will do much to help. Please refrain from necro-posting in old threads. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Vulture Posted May 7, 2014 Share Posted May 7, 2014 I disagree... Its 9 months later still and I was searching for help with @Comspec syntax..... I came across this thread and the @CRLF was exactly what I needed to fix my problem. So even though it may not have helped the O.P. It did help me and probably countless others who stumbled here looking for answers to similar problems... Thx for posting buscador... Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now