How can I start a batch script before logging in?

7

2

I have set up my computer to boot at the same time everyday when I am not home. I need it to run a batch file without anyone touching it right when it boots.

I have added a shortcut to the file in the "startup" folder. However, the script doesn't run until I log on and select the desktop from the metro interface.

Is there a way to have this script run without logging in?

Kreuzade

Posted 2013-02-08T00:04:56.050

Reputation: 173

Answers

0

You could use some of the windows utilities and turn a script into a service. I have done that before and there was information about doing this that was easily found.

More info: Best srvany.exe for Windows XP and Windows 7?

mdpc

Posted 2013-02-08T00:04:56.050

Reputation: 4 176

1

I used a tool called AlwaysUp as I could not find a means of turning a batch script into a service without use of a tool.

– Kreuzade – 2013-02-19T03:59:37.997

Found the reference about something that I had used to do this several years ago....it uses a Windows Server 2003 utility called srvany.exe. Here is some information on somebody using the process on Windows Server 2008: http://social.technet.microsoft.com/Forums/en-US/winserverMigration/thread/98a97aee-c62b-4683-94ab-3777899cf7de/

– mdpc – 2013-02-19T06:17:47.560

6

If you have Windows 8 Pro, open the search charm for apps using Windows logo key‌+Q, type gpedit.msc and open the Local Group Policy Editor.

  • Under Computer Configuration / Windows Settings you'll find Scripts (Startup/Shutdown)

  • Under User Configuration / Windows Settings you'll find Scripts (Logon/Logoff)

Specify your batch file or PowerShell script here.

Karan

Posted 2013-02-08T00:04:56.050

Reputation: 51 857

This seemed to work once I typed in my password, not before. Any way to make it happen before? – Kreuzade – 2013-02-08T00:39:40.507

1Logon scripts under User Configuration run with user-level credentials, so AFAIK the user has to log in first. You could try a startup script instead, or perhaps have the logon script execute after the password is entered (as above), but delay the desktop from being loaded until the script has completed executing. For this, Enable Computer Configuration / Administrative Templates / System / Scripts / Run logon scripts synchronously. – Karan – 2013-02-08T00:53:42.233

0

Follw the steps on this URL. It shows you how you can also start a PowerShell script (which is more preferred instead of a batch script):

http://teusje.wordpress.com/2012/09/11/windows-server-logging-users-logon-and-logoff-via-powershell/

juFo

Posted 2013-02-08T00:04:56.050

Reputation: 318

So how is this any different from what I posted? The exact same dialog allows you to specify batch files or PowerShell scripts. Also, link-only answers are not preferred here. To protect from link rot, always add as much as you can of the information here (but try not to plagiarise huge blocks of information word for word). – Karan – 2013-02-08T18:33:18.360

ok, sorry my bad. it included screenshots, which make it sometimes easier + shows you also the powershell. – juFo – 2013-02-10T12:16:16.210

1If you think an existing answer can be improved with screenshots, just add them! Or at the very least you should add them to your answer. – Karan – 2013-02-10T17:08:26.507

0

Did windows 8 do away with the Autoexec.nt file? When I have been lazy I have made a exe with rar with nothing but a batch file and needed programs. Then I set up that custom exe as a service. I have no idea if that can be done in 8. I know I shouldn't answer a question when I don't know the operating system, forgive me if I annoy.

Michael Mantion

Posted 2013-02-08T00:04:56.050

Reputation: 656