issue with starting and stopping services in script
Posted: 2011-06-09 02:44
Hi,
I have written a simple VB script that would stop the services of hMailServer and MySQL, then do the back up on hMailServer Data as well as the Data in MySQL Database, and then finally restarted the services.
The script goes as follows
When I run the script in the dos command prompt, it stops the hMailServer as well as MySQL services. Then after having done the task, the hMailServer will not get re-started because there is a message in the dos windows that says hMailServer needs to be started first. It is awaiting a user intervention to say a Yes or No to start the hMailServer.
Since I schedule the task to run overnight, the hMailServer will not get started until I come in the next day. I wonder if anyone might be able to share some of your expertise with me.
Any help would be greatly appreciated.
Thank you
I have written a simple VB script that would stop the services of hMailServer and MySQL, then do the back up on hMailServer Data as well as the Data in MySQL Database, and then finally restarted the services.
The script goes as follows
Code: Select all
Set objShell = CreateObject("WScript.Shell")
objshell.run("net stop ""hMailServer""")
objshell.run("net stop ""mysql""")
sourceDataStr = "C:\Program Files\hMailServer\Data"
destDataStr = "E:\hMailServer\Data"
sourceSQLStr = "C:\AppServ\MySQL\data\hmailserver_db"
destSQLStr = "E:\hMailServer\mysql daily backup"
' Back up Email Data
strDataCmd = "robocopy " & Chr(34) & sourceDataStr & Chr(34) & " " & Chr(34) & destDataStr & Chr(34) & " /M"
objShell.Run strDataCmd
' Back up mysql database
strSQLCmd = "robocopy " & Chr(34) & sourceSQLStr & Chr(34) & " " & Chr(34) & destSQLStr & Chr(34) & " /MIR"
objShell.Run strSQLCmd
objshell.run("net start ""hMailServer""")
objshell.run("net start ""mysql""")
WScript.Quit
Since I schedule the task to run overnight, the hMailServer will not get started until I come in the next day. I wonder if anyone might be able to share some of your expertise with me.
Any help would be greatly appreciated.
Thank you