First of all, thank you all for the knowledge I receive when reading Tek-Tips! Without all of you, I would not have as much knowledge about scripting as I do.
My question is, I created a script that backs up certain files to our network and put the script on the local computer. I then created a script that creates a scheduled task every hour that runs my backup script. Here is the scheduled task script:
------------------------------
Set objNewJob = objWMIService.Get("Win32_ScheduledJob")
errJobCreated = objNewJob.Create _
("C:\Backup.vbs", "********010000.000000-300", _
True , 1 Or 2 OR 4 Or 8 OR 16 Or 32 Or 64, , , JobID)
------------------------------
The above script is set to run at 1:00 AM and I have one for every hour.
The problem is the backup.vbs script runs just fine when it is run manually. When the task scheduler runs it, I get an error that it cannot find the network path. If I change the AT Service account to the user ID and password of the current logged in user, the task scheduler works great and kicks off the backup.vbs without a problem.
When scheduled tasks are created using the script above it creates the scheduled task as NT AUTHORITY/SYSTEM. I believe that since the task is running as NT AUTHORITY/SYSTEM and not the user, I am getting the error.
I would like to know if there is a way to script either:
1. - A way to use the current logged in username and password into the scheduled task itself, OR
2. - A way to change the AT Service Account using a script to grab the current logged in username and password.
Manually changing the AT Service Account is not really an option on all computers. I would prefer method #1 above, but #2 would work too.
I checked out some other threads here and also did some research but nothing seems to show the ability to run the scheduled tasks as anything other than NT AUTHORITY/SYSTEM.
Any help or thoughts of different ways to schedule the tasks is greatly appreciated.
Thanks in advance! Have a great day.
Pellet
My question is, I created a script that backs up certain files to our network and put the script on the local computer. I then created a script that creates a scheduled task every hour that runs my backup script. Here is the scheduled task script:
------------------------------
Set objNewJob = objWMIService.Get("Win32_ScheduledJob")
errJobCreated = objNewJob.Create _
("C:\Backup.vbs", "********010000.000000-300", _
True , 1 Or 2 OR 4 Or 8 OR 16 Or 32 Or 64, , , JobID)
------------------------------
The above script is set to run at 1:00 AM and I have one for every hour.
The problem is the backup.vbs script runs just fine when it is run manually. When the task scheduler runs it, I get an error that it cannot find the network path. If I change the AT Service account to the user ID and password of the current logged in user, the task scheduler works great and kicks off the backup.vbs without a problem.
When scheduled tasks are created using the script above it creates the scheduled task as NT AUTHORITY/SYSTEM. I believe that since the task is running as NT AUTHORITY/SYSTEM and not the user, I am getting the error.
I would like to know if there is a way to script either:
1. - A way to use the current logged in username and password into the scheduled task itself, OR
2. - A way to change the AT Service Account using a script to grab the current logged in username and password.
Manually changing the AT Service Account is not really an option on all computers. I would prefer method #1 above, but #2 would work too.
I checked out some other threads here and also did some research but nothing seems to show the ability to run the scheduled tasks as anything other than NT AUTHORITY/SYSTEM.
Any help or thoughts of different ways to schedule the tasks is greatly appreciated.
Thanks in advance! Have a great day.
Pellet