Solved

Scheduling task using AT not working

Posted on 2002-05-23
9
208 Views
Last Modified: 2010-04-13
I'm trying to schedule a task using AT.  The command is as follows:

at 16:00 cmd /c \"reg query "HKCU\SOFTWARE\Microsoft\Internet Explorer\T
ypedURLs" >> log.txt\"

If I just type the reg query command on the command line, it pipes the output fine to the log.txt file.  But as soon as I put it in an AT command, all I get in the log.txt file is:
"The system was unable to find the specified registry key."

I next tried creating a batch file with the reg query command in it and used the at command as follows:

at 16:00 cmd /c c:\temp\log.bat

That once again gave the same output in the log.txt file.  If I run the log.bat from the command line, it gives me the output I'm looking for in log.txt.

I tried adding some pause commands to the log.bat file when the AT utility ran it to see what was happening and nothing appeared wrong.  So I'm not sure what is wrong.

Any ideas?  Oh, and I don't want to use scheduled tasks either.  Prefer to use AT.

Shane
0
Comment
Question by:SigTau66
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +2
9 Comments
 
LVL 41

Expert Comment

by:stevenlewis
ID: 7031011
I think it is a permission issue
with scheduled tasks you can specify the username and password
http://support.microsoft.com/search/preview.aspx?scid=kb;en-us;Q300160
you can try incorperating the runas command in the bat file
0
 
LVL 41

Expert Comment

by:stevenlewis
ID: 7031015
0
 
LVL 63

Expert Comment

by:SysExpert
ID: 7031076
try using  
cmd.exe /k for interactive batch files.

I hope this helps !
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 14

Accepted Solution

by:
AvonWyss earned 200 total points
ID: 7031284
By default, jobs created by AT run in the system context. THe system context, however, will have virtually no registry keys in the HKEY_CURRENT_USER branch. So, what you can do, it to open Control Panel, go to the Sheduled Tasks, and modify that task you have created using AT to use the user you want to run.

Note that you will probably not be able to export that registry key from *any* currently logged in user, but only for the user you defined in the task properties. If that's fine with you, go for it.
0
 
LVL 7

Expert Comment

by:franka
ID: 7032096
have you tried the "interactive" switch?

it lets the task run in the context of the logged on user.


at 16:00 cmd.exe /interactive /c \"reg query "HKCU\SOFTWARE\Microsoft\Internet Explorer\T
ypedURLs" >> log.txt\"
0
 

Author Comment

by:SigTau66
ID: 7032445
Steven:  I had already looked at those MS articles and still couldn't figure it out.  Thanks for taking your time to submit an answer.

SysExpert & Franka:  Already did the /k command and it still didn't work along with the interactive switch.  And I'm trying to make this as hidden as possible so the person doesn't know they're having their browser history watched.

The correct and accepted answer was by AvonWyss.  The 3-4 hours I spent researching this problem, I don't know how many times I read about the AT command running in the system context and never thought that it wouldn't have permission to read that registry key.  I submitted the same scheduled command as yesterday, but this time I went to that task in Scheduled Tasks and had it runas the administrator on the machine and it worked perfectly.  

I appreciate all the help from everybody.

Shane
0
 
LVL 7

Expert Comment

by:franka
ID: 7032706
now you don't need the /interactive switch?
0
 
LVL 14

Expert Comment

by:AvonWyss
ID: 7033391
Shane, thank you for accepting my answer. However, from your comment, I am not sure whether you may still be missing a part of your "quest" with the system context. That is, the problem is not a permission issue at all.

The registry is mainly divided in two parts, the machine specific part and the user specific part. The user specific part is stored and managed completely individually for each user on the system. This is the HKCU key.

Now, any application or service has to run in a user context (which will then also provide an individual user key in the registry). The "system" context is therefore only sort of a special user, and what you were doing is to read its registry (which did not work out since the system context never ran Internet Explorer).

This said, it should be clear that the exported registry part will be out of the registry of the user you have assigned to the AT command, and not from the currently logged on user.
0
 

Author Comment

by:SigTau66
ID: 7034613
AvonWyss:

Yeah, I found that out running the command with the runas portion of the scheduled task.  After you gave me the answer, I realized I wasn't going to be able to pull that key out for the user I wanted on that PC.  So it looks like I won't be able to get that person's partial history of their Internet usage.  But, you answered my question in the aspect of why it wasn't working.  Which was all I was looking for at this point. :)

I'll continue on with my search for getting someone's Internet history without them knowing it.  Thanks anyway.
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question