0

Most of the questions relating to this seem to be centered on hiding the command prompt window when running a batch file at startup. I seem to be having the opposite problem.

I'm trying to run a batch file on startup as an administrator, and without having to click through the UAC prompt. I have followed the instructions here, and have set up a scheduled task to invoke a batch file. The thing is, I cannot get a command prompt to start and remain open. If I have a command line such as:

cmd /c "C:\Users\JoeBloggs\Batch\BackgroundBatchTask.bat"

and I run it from Start/Run, it opens a command window and invokes the batch file, which is what I want (BackgroundBatchTask.bat is a batch file that never exits). If I create a task to be run at startup with highest privileges and use the same command line, when I test it by right-clicking on the task and selecting "run", I see the task start in the task manager, but there is no window. What could my problem be? (and yes, the hidden checkbox is not checked).

4
  • is your account standard user account and no admin account? here Windows runs the cmd in a new session and so you can't see it Commented Nov 3, 2015 at 5:31
  • Thanks @magicandre1981. The account is an admin one. I must confess I am a bit hazy (well a lot hazy actually) on the difference between running an application with admin privileges, and running an application when logged in as an administrator. As I want to run this task at startup - at which time presumably no-one is logged in - maybe that is affecting how Windows presents the application when it is started from the "Run" context menu of the scheduled tasks.
    – rossmcm
    Commented Nov 3, 2015 at 20:34
  • yes, this is your issue. Run it at logon of your admin user, but no at start Commented Nov 4, 2015 at 5:19
  • Ok, but what if I want the task to be started on starting windows? Do I need to use runas in that case?
    – rossmcm
    Commented Nov 4, 2015 at 7:58

1 Answer 1

0

You could you use the run key:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run

create an entry:

MyBatch = (REG_SZ) 'cmd /c "C:\Users\JoeBloggs\Batch\BackgroundBatchTask.bat"'
1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .