Jump to content

@Comspec not found??

Recommended Posts


***By mistake I posted this in the General Developers and I can't find how to delete it, I'm sorry!!***


Sorry if this is a newbie question. I'm still learning quite a bit of AutoIT and I'm a confused.

Context: I'm developing a script that will be attached to a scheduled task. The script will run every 10 minutes and if the conditions are met it will stop a custom service, wait a second and start it again. 

My problem is when the script tries to stop the service: I'm using the following code: 

If($restart) Then
    $handlerstop = RunWait (@Comspec & "/c" & 'net stop GoldenEye.Handler')
    $handlerstart = RunWait (@Comspec & "/c" & 'net start GoldenEye.Handler')
    FileWriteLine($handler_log, $current_time&": Restarting Handler")

 restart is a binary variable to check the condition. 

When I run the script, cmd.exe does not pop and I get @error=1 and @extended=2 . As far as I understand, the @extended macro stores the windows error code and a value of 2 means "file not found" . this means that for some reason AutoIt is not finding cmd.exe?? 

I did try running a ping command, to check if for some reason it was not finding the command, with the same results.

I'm running the script with a full admin account (IsAdmin() returns 1) so the net command executes without problem from a user command prompt. 

System is Windows 10 x64.

I've read the help files for Run, RunWait, RunAs, RunasWait and all the forum threads related to similar issues, and at this point I'm a bit dizzy... what I'm missing? 




Share this post

Link to post
Share on other sites

Same answer here. Remarks on help about RunWait says:

To run DOS commands, try RunWait(@ComSpec & " /c " & "commandName")    ; don't forget " " before "/c"

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post

Link to post
Share on other sites

Thank you!! (saw the other thread before this one, please someone delete it!) 

Yes, I had missed that space character, now it works perfectly. 

I feel so stupid, but I'm learning and won't happen again, 



Share this post

Link to post
Share on other sites

net.exe is it's own executable, and not a cmd.exe command, so calling @compspec does nothing but waste resources.

This should do it:

$handlerstop = RunWait ('net stop GoldenEye.Handler')


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