Рет қаралды 2,744
I tried to schedule my own task in Windows 10, and as of today November 2019 there's a bug in the wizard that prevented me from creating it until I found a workaround. I'm going to show you the bug, and what I did to get around it.
First, I'm going to create a working example task in the tradition of "hello world" so that I can use it to demonstrate the problem.
I'm using the windows key plus 'r' to run a program by name. I'll start by making a directory to put my demo files in. Then I'll change directory to it, and use notepad to create a very simple visual basic script file.
I'll just put a message box that says hello. And if I run that by typing its name, you'll see what it does.
And incidentally, if I bring up the folder with this file in it, and double click it, the same message box comes up.
So I'm going to use this example task to demonstrate the process of using the task scheduler wizard, as though I wanted to do this task every day or upon some other trigger. You can find the task scheduler wizard somewhere in the Windows Administrative Tools, but I find it easier to remember the name.
So this is what the task scheduler looks like, we go into the tasks library. You'll probably find tasks in there that applications have added for themselves, but I'm going to add my own. Right click and "Create a Basic Task..." you'll have to give it a name. But for the purposes of this demonstration, I'll keep the defaults since I don't even need to get it to trigger. The important bit is that under "Start a Program" I browse to my "hello" file and accept the path to it. After clicking "Finish" the task would be set to run every day at this time, but I can run it immediately with the context menu. And in this case, it works as it should.
OK, I'll get rid of that working one and show how it goes wrong. I'm going to go into my folder structure, go up one folder and rename KZbin to You Tube. Now I'm going back to the task scheduler and do exactly what I did before, but with the file in the renamed location.
OK it all looks the same, but when I try to run the program it asks me "How do you want to open this file?". This seems a very strange question until you realise what happened here. To demonstrate, I'll pick "Notepad" because it gives a useful error message. Here we go: It "Cannot find the file" which is darn strange since we just browsed to it with file explorer. But look carefully at the file it can't find: it stops at the space. There's clearly a parsing error due to the space in the file name. It's added ".txt" as a default extension for Notepad. I can tell you, I looked for a way to fix this with all different kinds of quoting on the path, but if I tried to add quotes, the wizard tried to handle the space by parsing what followed as command parameters. Basically the wizard and the scheduler disagreed about the number of quotes present.
I did find a sane workaround, and I'll show it to you. I had to use the export/import mechanism. I use the context menu on the broken task, and choose "Export..." which saves it to an xml file. I'm going to edit it with notepad++ because of syntax highlighting but you can use the regular one.There's the path of the command. It already has quotes, so the task scheduler obviously adds another layer of quotes and they end up cancelled out. I'll remove the quotes and save the file.
Now, let's try adding that. I need the "Import..." option. There it is, opens in the right folder to its credit. Oh, OK, I can't have two tasks with the same name, the broken one is still there, so I'll add a 1 to this one's name. Accept that and try it, and there we are, it's working again even with the space in the name.
I hope that made sense and the workaround is useful for you, and as always, thanks for watching to the end.