Windows: Batch File to Run Every Time Computer Boots

warcrow

Lifer
Jan 12, 2004
11,093
11
81
Hi guys,

Need some help here is some WinXP batch files.

In the office we have some loaner laptops. We plan to lock down the laptop USB ports for security reasons. Management does not want to disable the ports via the BIOS but via a script we've come up with (I've attached the USB code to disable the ports.) so basically it's easy on and easy off (scripts localed on the C drive for admins only).

Objective:

Run a batch file every time a computer boots.


I've tried:

Start Up Folder
To make things easy I was going to drop the script into the Start Up folder under all users, but realized that wouldnt work because you have to be an admin permissions to run the script and we make all users use the guest account.

Autoexec.bat
I've tried dropping the code into the autoexec.bat so that it runs every time the computer boots, but for some reason it doesnt run.

Registry
I have now moved on to the registry. I figured this is the best way to make it run all the time. I when to:

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run


Added a key with: C:\System32\cmd.exe /c yourpath\yourbatch.bat

no dice. Anyone have any suggestions or know what might be going on?





 

Ken g6

Programming Moderator, Elite Member
Moderator
Dec 11, 1999
16,284
3,905
75
Yep, Scheduled Tasks should do it. You can run a task, at System Startup, as a given user, if you enter that user's password.
 

warcrow

Lifer
Jan 12, 2004
11,093
11
81
Good suggestion, but the problem is that we re-image these machine very often so it would require setup every time.

I'm looking for something more automatic. I think the best bet is to go with Group Policy. I'm actually currently trying to figure out how to write to local GP on the machine via command line. That would be great, but Google isnt helping me out much.
 

warcrow

Lifer
Jan 12, 2004
11,093
11
81
Originally posted by: drebo
Domain logon script is the way I'd do this.

This cannot be a login script, it needs to be a Startup script. A login script utilizes a users permissions to run a login script and we need admin rights to disable USB thumb drives.
 

warcrow

Lifer
Jan 12, 2004
11,093
11
81
Originally posted by: hopeless
Have you tried saving your code as a seperate file, than placing a line in the autoexec to run that file?

In the OP I mention this yes. I tried dropping the code (didnt work) and making a "CALL" to the batch. Neither worked unfortunately.
 

Apathetic

Platinum Member
Dec 23, 2002
2,587
6
81
Originally posted by: warcrow
Good suggestion, but the problem is that we re-image these machine very often so it would require setup every time.

I'm looking for something more automatic. I think the best bet is to go with Group Policy. I'm actually currently trying to figure out how to write to local GP on the machine via command line. That would be great, but Google isnt helping me out much.

I'm confused. Can't you just add the scheduled task to the image?

Dave
 

warcrow

Lifer
Jan 12, 2004
11,093
11
81
Originally posted by: Apathetic
Originally posted by: warcrow
Good suggestion, but the problem is that we re-image these machine very often so it would require setup every time.

I'm looking for something more automatic. I think the best bet is to go with Group Policy. I'm actually currently trying to figure out how to write to local GP on the machine via command line. That would be great, but Google isnt helping me out much.

I'm confused. Can't you just add the scheduled task to the image?

Dave

Management doesnt want to create a new image here, and a scheduled task uses login credentials.
 

drebo

Diamond Member
Feb 24, 2006
7,035
1
81
Use Symantec Endpoint Protection. It has the capability to disable USB port access, among other removable storage capabilities.
 

Ken g6

Programming Moderator, Elite Member
Moderator
Dec 11, 1999
16,284
3,905
75
Scheduled tasks seem to be stored in .job files in c:\%WINDIR%\Tasks. I'm not sure if the password is stored in there, but if it is, couldn't you just push out that file?
 

warcrow

Lifer
Jan 12, 2004
11,093
11
81
Originally posted by: drebo
Use Symantec Endpoint Protection. It has the capability to disable USB port access, among other removable storage capabilities.

Really? Interesting.

We actually do use SEP in our environment. Does it completely disable USB access? We have USB KBs and Mice. The script that we've developed just disabled USB thumb drives.

I'll chat with out security (SEP admins) team and see if they can shed some light on this.
 

warcrow

Lifer
Jan 12, 2004
11,093
11
81
Originally posted by: JACKDRUID
user profiie -> logon script

hardware profile with disabled usb drive

Thanks for the effort JACKDRUID but unfortunately this has been addressed in this thread.
 

tfinch2

Lifer
Feb 3, 2004
22,114
1
0
Originally posted by: Ken g6
Scheduled tasks seem to be stored in .job files in c:\%WINDIR%\Tasks. I'm not sure if the password is stored in there, but if it is, couldn't you just push out that file?

That's what I do on our W2K systems that do not have the capability to create scheduled tasks from the CLI. The task can run as NT Authority\System user with no password required.

For W2K3+ systems, use the schtasks command.
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |