-
shell problems
The code below is an exert of my program. It allows the user to easly schedule a copy using robocopy and shedule task manager. The problem is it is only working when you have the "Weekly" check box checked and not the others. I am not sure what to do as I am positive the code is right. How can I use shell command so that when it opens up the shell it will leave it up so that I can see exactly what is happening? I have it set up to put all the logs in a file but it is not even creating a log.
Code:
Dim Often As String = String.Empty
Select Case True
Case Radiohourly.Checked : Often = "HOURLY"
Case Radiodaily1.Checked : Often = "DAILY"
Case RadioWeekly1.Checked : Often = "WEEKLY"
Case Radiomonthly1.Checked : Often = "MONTHLY"
End Select
Code:
schedule = "SCHTASKS /Create /SC " & Often & " /D " & startday & " /RU Administrator /RP " & password & " /ST " & TextTime.Text & ":00" & " /TN " & """" & title & """" & " /TR " & """" & path & """" & " > " & """" & "C:\copypal\slogs\" & title2
Shell("cmd /c" & schedule, vbHide)
-
Re: shell problems
First thing I would say is dont use Shell, use Process.Start.
Second thing is, if you are using Shell and you dont want it to hide the window, surely the first thing you might try changing is the part of the Shell command that says "vbHide" ?
Third thing - the way you are combining the strings means that there is no space between the /c after cmd and the SCHTASKS command. So what you actually end up with when the program runs is this:
Code:
"cmd /cSCHTASKS /Create ... etc"
where as it should be this:
Code:
"cmd /c SCHTASKS /Create ... etc"
-
Re: shell problems
so i can do just process.start(schedule) ? because that is not working. also adding a space after /c didn't help either
-
Re: shell problems
No you can do:
Code:
Process.Start("cmd", "/c " & schedule)
If that still doesnt do what you want then your command line must not be correct - you can check what it actually looks like when it is all put together by setting a breakpoint in your code and then when the breakpoint gets hit you hover the mouse over "schedule" variable and it will show you the contents of it. If you dont know how to do that then you could just use a messagebox instead, like this:
Code:
MessageBox.Show(Schedule)
Also, doesnt robocopy have a schedule feature built into it anyway?