Developers Jos Posted October 4, 2017 Developers Share Posted October 4, 2017 I would start with trying to run the command like this and see what happens: run(@ComSpec & ' /k SQLCMD -S.\SQLSERVER -E -Q "BACKUP DATABASE DBName TO DISK=''C:\DBBackup\DBBackup.bak'' WITH INIT"') When that works we can start building it out with the variables. Jos 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...
Nunos Posted October 4, 2017 Author Share Posted October 4, 2017 That opened up a cmd console and ran the only thing it didn't do was close and log, but I suspect that is because the -o switch was omitted. So is it possible my variables are not passing through properly or perhaps that cmd window is getting stuck??? Link to comment Share on other sites More sharing options...
Developers Jos Posted October 4, 2017 Developers Share Posted October 4, 2017 Nope, the intent was for it to stay open to see any errors and that is why it has a /k at the start. /c will close that window, but that is of later concern. So now with the variables in it which I assume you have define in your script: run(@ComSpec & ' /k sqlcmd -S ' & $Server & ' -E -Q "BACKUP DATABASE ' & $DBName & ' TO DISK=''' & $Destination & ''' WITH INIT"') Jos 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...
Nunos Posted October 4, 2017 Author Share Posted October 4, 2017 Yes that seems to have worked as well except for the log file. Link to comment Share on other sites More sharing options...
Developers Jos Posted October 4, 2017 Developers Share Posted October 4, 2017 So have you tried adding that to the working commandline? if so and not working then please show what you have. Jos 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...
Nunos Posted October 4, 2017 Author Share Posted October 4, 2017 run(@ComSpec & ' /k sqlcmd -S ' & $Server & ' -E -Q "BACKUP DATABASE ' & $DBName & ' TO DISK=''' & $Destination & ''' WITH INIT"' '-o' &$LogFile' ) I did try but it didn't work. The ' placing doesn't make sense yet to me. Do I need to add one each time I pass a variable in like $Logfile ? And do they need to both proceed and follow? Very confusing to me at the moment I apologize for all the questions. Link to comment Share on other sites More sharing options...
Developers Jos Posted October 4, 2017 Developers Share Posted October 4, 2017 Try this: run(@ComSpec & ' /k sqlcmd -S ' & $Server & ' -E -Q "BACKUP DATABASE ' & $DBName & ' TO DISK=''' & $Destination & ''' WITH INIT" -o ' & $LogFile ) unsure whether you need a space between -o and the filename, just try it both in case this doesn't work. Jos Nunos 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...
Nunos Posted October 4, 2017 Author Share Posted October 4, 2017 It works. I also changed the @comspec /k to /c and the cmd console vanishes after the script executes. Thank you for the assistance!!! Do you know what I can do in the documentation to learn about the apostrophe and ampersand rules? Link to comment Share on other sites More sharing options...
Developers Jos Posted October 4, 2017 Developers Share Posted October 4, 2017 You are welcome. As to learning about the proper use of single and double quotes. It helps when you use SciTE with its syntax highlighting and read up on it in the Help file. The rest is a matter of practice and taking steps like it did with you today. When you don't want to see any window at all, you could set the 3rd parameter of the run()command like: run(@ComSpec & ' /c sqlcmd -S ' & $Server & ' -E -Q "BACKUP DATABASE ' & $DBName & ' TO DISK=''' & $Destination & ''' WITH INIT" -o ' & $LogFile,Default,@SW_HIDE) Have fun, Jos 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...
Nunos Posted October 4, 2017 Author Share Posted October 4, 2017 Awesome I will add the @SW_Hide for sure. Thank you again so much for the help. 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