wardy Posted May 24, 2007 Posted May 24, 2007 Hi all, just getting into Autoit and so far really like it but have gotten well stuck on this. Trying to query some remote services using SC. Works a treat if the service name has no spaces in it. But, if the service name has a space it throws an error. Any sugestions or points would be most welcome! This works a treat $service = "Messenger" Run(@ComSpec & " /c " & "sc \\" & "Exchange1 " & "query " & $service & " >>C:\Scripts\AVCheck\test.txt", "", @SW_HIDE) This doesn't! $service = "McAfee GroupShield" Run(@ComSpec & " /c " & "sc \\" & "Exchange1 " & "query " & $service & " >>C:\Scripts\AVCheck\test.txt", "", @SW_HIDE)
ResNullius Posted May 25, 2007 Posted May 25, 2007 This works a treat $service = "Messenger" Run(@ComSpec & " /c " & "sc \\" & "Exchange1 " & "query " & $service & " >>C:\Scripts\AVCheck\test.txt", "", @SW_HIDE) This doesn't! $service = "McAfee GroupShield" Run(@ComSpec & " /c " & "sc \\" & "Exchange1 " & "query " & $service & " >>C:\Scripts\AVCheck\test.txt", "", @SW_HIDE) Hi, and welcome to a great community of users. Commands, filenames, and/or options with spaces in them must be enclosed in quotes when used on the command line. So, you can do this: $service = "McAfee GroupShield" $service = CHR(34) & $service & CHR(34) ; chr(34) is ascii code for " quotation mark Run(@ComSpec & " /c " & "sc \\" & "Exchange1 " & "query " & $service & " >>C:\Scripts\AVCheck\test.txt", "", @SW_HIDE)oÝ÷ Úò¢çéyÛayÈkßý²)ò¢êÜ¢iÙbæ®¶sbb33c·6W'f6RÒgV÷C´Ö4fVRw&÷W6VÆBgV÷C°¥'Vâ6öÕ7V2fײgV÷C²ö2gV÷C²fײgV÷C·62b3#²b3#²gV÷C²fײgV÷C´W6ævSgV÷C²fײgV÷C·VW'gV÷C²fײ4"3Bfײb33c·6W'f6Rfײ4"3BfײgV÷C²fwC²fwC´3¢b3#µ67&G2b3#´d6V6²b3#·FW7BçGBgV÷C²ÂgV÷C²gV÷C²Â5uôDRoÝ÷ Úò¢çëiÊ&n)Ú¶*'¡û" ^jw]¢æåz«¨µë"*.Ê&©Ý)ÞêeiDz¢êÞÆ+-x¢æåz«¨µë0Ølx%zƧvëvë®§w*.®Ç«¾'©)¶¬jëh×6$service = "McAfee GroupShield" Run(@ComSpec & ' /c ' & 'sc \\' & 'Exchange1 ' & 'query "' & $service & '" >>C:\Scripts\AVCheck\test.txt', "", @SW_HIDE)oÝ÷ Øky©eÉשzwl¢|!jÝý±æ¬ë-~ò¢ëh~e£)z»(©eÊÞ}êèê¶øÁ¬¬jÈßÛ,¢gg¬ªÝ¶zkiÉ(~ȧW×h¹¹^ªê-zÌ!z{a{-ýêâ[zÈyæaz°%²7öiè¶Ë«{rÊ·ö·æ¤x.§*.Ê&©Ý)Þmëpyéíꮢßܪê-¶ªºlr«¨¶Ø^±êïz¹Úæ§vØ^ªç«ÉÊ&©ÝJ)©êåG+ºÚ"µÍÌÍÜÙXÙHH ][ÝÓXÐYYHÜÝÚY[ ][ÝÂ[ÛÛTÜXÈ [È ][ÝÈØÈØÈ ÌLÉÌLÑ^Ú[ÙLH]YH ][ÝÈ [ÈÒÍ H [È ÌÍÜÙXÙH [ÈÒÍ H [È ][ÝÈ ÝÉÝÐÎÌLÔØÜÉÌLÐUÚXÚÉÌLÝÝ ][ÝË ][ÝÉ][ÝËÕ×ÒQJ Hope that helps
wardy Posted May 27, 2007 Author Posted May 27, 2007 It certainly does help! Thank you for your time and on being so clear, ASCII codes huh.. I'll get reading... ) Ward
herewasplato Posted May 27, 2007 Posted May 27, 2007 Welcome to the forum.You don't need ComSpec to run sc.exe and you don't have to write the output of sc.exe to a file. AutoIt can "read" the output of sc.exe via the STDIO functions. Here is a small sample of how that can be done:$service = "messenger" $PID = Run("sc query " & $service, "", "", 3) While 1 $line = StdoutRead($PID) If @error Then ExitLoop MsgBox(0, "STDOUT read:", $line) $var1 = StringInStr($line, "STATE ") $var2 = StringMid($line, $var1, 22) $var3 = StringRight($var2, 1) MsgBox(0, "", ">>>" & $var3 & "<<<") WEnd...but AutoIt can also interface directly with Dynamic Link Libraries (DLLs) so you might want to look at this thread: http://www.autoitscript.com/forum/index.ph...;showtopic=6487...enjoy AutoIt... [size="1"][font="Arial"].[u].[/u][/font][/size]
wardy Posted May 29, 2007 Author Posted May 29, 2007 Wow, AutoIT gets even better! Thanks to all who've helped with this, going to have a play and incorporate this into my work. Cheers! Wardy
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