kcorbo Posted June 19, 2008 Share Posted June 19, 2008 I recently started using WPKG and have been trying to write a script in autoit to distribute through it. The script should run an installer via the command line, close a window that opens, then start the service associated with that install. It runs through the script without any failures but it's not actually executing the install on the command line. This has been driving me crazy and any help would be appreciated.MsgBox(0, "Notice", "Line 2")Run(@ComSpec & "/c" & '"C:\Program Files\nsclient\pNSClient.exe" /install', "", @SW_HIDE)Sleep(2000)MsgBox(0, "Notice", "Line 5") If WinExists("Information") Then WinActivate("Information")Else WinActivate("Error")EndIfSend("{ENTER}")Sleep(500)Run(@ComSpec & "/c" & 'NET START "NetSaint NT Agent"', "", @SW_HIDE)MsgBox(0, "Notice", "Service Started")The message boxes are just for error checking. Link to comment Share on other sites More sharing options...
Dambisa Posted June 20, 2008 Share Posted June 20, 2008 Could be " /c " instead of "/c" (space before and after quotes). Link to comment Share on other sites More sharing options...
kcorbo Posted June 20, 2008 Author Share Posted June 20, 2008 Ahhhhh, thank you so much. I can't believe I overlooked that. It makes so much sense. Everything worked beautifully. What would be the format for this line then if I wanted to use @ProgramFilesDir instead of a static path? I tried:Run(@ComSpec & " /c " & @ProgramFilesDir & '"\nsclient\pNSClient.exe" /install', "", @SW_HIDE)...but it came up with a parsing error during run time.Thanks again. Link to comment Share on other sites More sharing options...
MHz Posted June 21, 2008 Share Posted June 21, 2008 (edited) Run(@ComSpec & " /c " & @ProgramFilesDir & '"\nsclient\pNSClient.exe" /install', "", @SW_HIDE)...but it came up with a parsing error during run time.Yeah, you have a double quote in a bad place. Good practice to add a Msgbox prior to the function call with the command string in it to debug issues in the syntax.Your command string would evaluate to beC:\Windows\System32\cmd.exe /c C:\Program Files"\nsclient\pNSClient.exe" /installSome changes I made but the your lines of concern should be resolved.MsgBox(0, "Notice", "Line 2"); run pNSClient.exe installationRun('"' & @ComSpec & '" /c "' & @ProgramFilesDir & '\nsclient\pNSClient.exe" /install', "", @SW_HIDE); call function every 250ms to check for error titleAdlibEnable('_Error_check')Sleep(2000)MsgBox(0, "Notice", "Line 5"); wait for Information titleIf WinWait("Information", "", 10) Then While Not WinActive("Information") ; activate the Information title WinActivate("Information") Sleep(500) If Not WinExists("Information") Then ; quit the loop if title does not exist ExitLoop EndIf WEnd ; progress if the title is active WinWaitActive("Information") Send("{ENTER}")EndIfSleep(500); start a serviceRun('"' & @ComSpec & '" /c NET START "NetSaint NT Agent"', "", @SW_HIDE)MsgBox(0, "Notice", "Service Started")ExitFunc _Error_check() If WinExists('Error') Then WinActivate('Error') If WinActive('Error') Then Send('{ENTER}') EndIf EndIfEndFuncJust changed to make use of AdlibEnable to handle the error window and other minor changes. Edited June 21, 2008 by MHz Link to comment Share on other sites More sharing options...
kcorbo Posted June 21, 2008 Author Share Posted June 21, 2008 Thanks MHz. I just started using Autoit and the syntax is killing me compared to all other programming languages. I wasn't familiar with the Adlib functions. They seem really useful after seeing your example. 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