Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Tasks need to open a CMD window and pass net use commands, then do a DIR command, pipping the output to a file on the server. Log in as either me (Sysadmin) or with one of the system accounts and task will only run if I'm physically logged into the server. Run as batch file is set in security properties for both users (me and service account), security is granted to all directories, etc. It almost acts like a scheduled task, since it is not physically connected to a display can't create a CMD window and pass the WinID so the command can be sent. I'm guessing. Anyone know of a document that explains how the server handles initiation of a window if done via scheduled task and no attached user is associated with the task? If I log onto the box and run the scheduled tasks they run fine, but produce no errors or event log entries and then just show that it ran successfully and sets the next run time. Have tried both with the run if logged in checkbox on and off and makes no difference. Other tasks work fine, except that they are acting on local drives with no display writing or updating taking place, so I'm guessing the system either can't instantiate a window if no display is connected to a logged on user, or it can't establish a point if it is trying to create a virtual screen. You'd think it is just creating a memory map and then mapping it to a device to display, but that doesn't seem to be the case, but I can find no documentation on how the system handles a scheduled task and how to invoke a fake or virtual screen that it could write to so it appears that a user was connected. Thanks This is driving me nuts and I've tried everything I can think of as well as our network boys ideas and nothing seems to work.

share|improve this question

2 Answers 2

Tasks need to open a CMD window and pass net use commands, then do a DIR command, pipping the output to a file on the server

You can't map drives if you aren't logged into the box. Try modifying your script so that it does a directory listing on the UNC path, that should work fine.

share|improve this answer

You can map a drive in a batch file. For instance, here you map to drive Z a share on server SERVER01 using the username DOMAIN\somebody and password "1234":

net use Z: \\SERVER01\share 1234 /USER:DOMAIN\somebody /PERSISTENT:NO

dir Z:\ > c:\dir.txt

net use z: /delete
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.