Scheduled tasks questions

"Please leave a message at the beep, we will get back to you when your support contract expires."

Moderators: phlip, Larson, Moderators General, Prelates

Scheduled tasks questions

Postby bentheimmigrant » Fri Apr 13, 2012 10:37 am UTC

I wrote a simple cmd script to be called up by windows scheduled tasks at 1am and run SyncToy for my backups. The problem is that one of the backup locations is on a network drive, which windows doesn't think is connected until you click on it. So the script starts by opening explorer to that drive, which works fine when run by me.

My question:
Will scheduled tasks (which starts the computer to run) turn off the computer again now that explorer has been opened? Both the script and SyncToy close themselves after they're finished, but I don't know how to close explorer (kill explorer.exe is a bit too heavy handed, unsurprisingly). If I do need to shut the explorer window, how would I do it?
"Comment is free, but facts are sacred" - C.P. Scott
User avatar
bentheimmigrant
The Good Poster
 
Posts: 1120
Joined: Fri Apr 25, 2008 9:01 pm UTC
Location: UK

Re: Scheduled tasks questions

Postby Yakk » Fri Apr 13, 2012 12:04 pm UTC

As a thought:
http://www.sevenforums.com/tutorials/44 ... older.html
create an explorer window in a new process. When you create this new process, determine what it's process ID is.

Kill (politely) said process ID, so it closes down nicely. (You could, in theory, even send a WM_CLOSE type message to the window associated with the process).

The "send a windows message to the window" technique should be possible without the "do it in a new process" technique.

I don't know of a way to do either of the above programatically off the top of my head. But it will be possible.
One of the painful things about our time is that those who feel certainty are stupid, and those with any imagination and understanding are filled with doubt and indecision - BR

Last edited by JHVH on Fri Oct 23, 4004 BCE 6:17 pm, edited 6 times in total.
User avatar
Yakk
 
Posts: 10038
Joined: Sat Jan 27, 2007 7:27 pm UTC
Location: E pur si muove

Re: Scheduled tasks questions

Postby Ubik » Fri Apr 13, 2012 12:22 pm UTC

Wouldn't it make sense to just open the connection to the network drive via command line command? The "net use" command possibly would be one to check: link to Microsoft kb. You can map and disconnect a drive with it.
User avatar
Ubik
 
Posts: 801
Joined: Thu Oct 18, 2007 3:43 pm UTC

Re: Scheduled tasks questions

Postby Yakk » Fri Apr 13, 2012 12:33 pm UTC

Bah, that doesn't answer ben's question. It just solves ben's problem.
One of the painful things about our time is that those who feel certainty are stupid, and those with any imagination and understanding are filled with doubt and indecision - BR

Last edited by JHVH on Fri Oct 23, 4004 BCE 6:17 pm, edited 6 times in total.
User avatar
Yakk
 
Posts: 10038
Joined: Sat Jan 27, 2007 7:27 pm UTC
Location: E pur si muove

Re: Scheduled tasks questions

Postby bentheimmigrant » Fri Apr 13, 2012 1:45 pm UTC

Ubik wrote:Wouldn't it make sense to just open the connection to the network drive via command line command? The "net use" command possibly would be one to check: link to Microsoft kb. You can map and disconnect a drive with it.

It is already mapped, all I have to do is navigate to it to activate it, as it were. Remapping it seems excessive (although I suppose it wouldn't hurt anything...)
My method works fine for on-demand runs, and may well work fine with Scheduled Tasks - but I don't know, and testing is more demanding than I want to face at the moment!
Yakk wrote:Bah, that doesn't answer ben's question. It just solves ben's problem.
This is also the issue!
"Comment is free, but facts are sacred" - C.P. Scott
User avatar
bentheimmigrant
The Good Poster
 
Posts: 1120
Joined: Fri Apr 25, 2008 9:01 pm UTC
Location: UK

Re: Scheduled tasks questions

Postby Yakk » Fri Apr 13, 2012 2:34 pm UTC

Have you tried running "dir" on it instead (or something).

I'm not sure what this "activation" consists of, honestly.
One of the painful things about our time is that those who feel certainty are stupid, and those with any imagination and understanding are filled with doubt and indecision - BR

Last edited by JHVH on Fri Oct 23, 4004 BCE 6:17 pm, edited 6 times in total.
User avatar
Yakk
 
Posts: 10038
Joined: Sat Jan 27, 2007 7:27 pm UTC
Location: E pur si muove

Re: Scheduled tasks questions

Postby bentheimmigrant » Fri Apr 13, 2012 2:41 pm UTC

Yakk wrote:Have you tried running "dir" on it instead (or something).

I'm not sure what this "activation" consists of, honestly.
I've not tried dir. The "activation" is simply that when the computer turns on it sometimes thinks that the network drive is disconnected, so I navigate to it, and the PC realises it's connected. If I run synctoy without letting the computer see that the drive is really there, synctoy can't find it, and gives up. Unless you mean you don't know what it consists of on the computer's side, in which case, neither do I.

One of the difficulties in all this is that I can't find a way to reproduce the network drive being "disconnected", as actually disconnecting it unmaps it. So I can't run loads of trials to see what works. :?
"Comment is free, but facts are sacred" - C.P. Scott
User avatar
bentheimmigrant
The Good Poster
 
Posts: 1120
Joined: Fri Apr 25, 2008 9:01 pm UTC
Location: UK

Re: Scheduled tasks questions

Postby bentheimmigrant » Mon Apr 16, 2012 2:07 pm UTC

Update:

Well, apparently it didn't find the drive. I'll use dir and see if that works, and if not I'll have to remap.
"Comment is free, but facts are sacred" - C.P. Scott
User avatar
bentheimmigrant
The Good Poster
 
Posts: 1120
Joined: Fri Apr 25, 2008 9:01 pm UTC
Location: UK

Re: Scheduled tasks questions

Postby Sero » Thu Apr 19, 2012 3:15 am UTC

Having done some work with something similar to this recently, and running into similar problems:

When you say you navigate to it and activate it, you mean you bring up, say, my computer, and double click on the disconnected network drive and it connects?

I'm pretty sure all that is doing is accessing the saved connection info and mapping the drive, that it still shows up in my computer doesn't mean it's still mapped.

I ended up using a net use script.
Princess Marzipan wrote:Dear God, we seriously just went and dug up CITATIONS for TORTURE being a WAR CRIME.

We have been fucking TROLLED, dear readers.
Sero
 
Posts: 321
Joined: Thu Jan 24, 2008 2:31 am UTC

Re: Scheduled tasks questions

Postby bentheimmigrant » Thu Apr 19, 2012 9:24 am UTC

Well, single clicking, but yeah. I ended up using net use, and it seems to have worked. It is odd, though, that directing the computer to it doesn't work, even if it was recalling the connection.
"Comment is free, but facts are sacred" - C.P. Scott
User avatar
bentheimmigrant
The Good Poster
 
Posts: 1120
Joined: Fri Apr 25, 2008 9:01 pm UTC
Location: UK


Return to The Help Desk

Who is online

Users browsing this forum: shealtket and 4 guests