c7c4c7
asked on
VB Script error when using Task Scheduler
I'm running a Robocopy using vbs, on a machine using Win 10 Professional. When I run it using Task Scheduler I get
Error 3 Accessing Source Directory
When I run it from a cmd window, not as an administrator, it runs with no problems.
Task Scheduler is set to run as a user that has administrator rights
What am I doing wrong
Error 3 Accessing Source Directory
When I run it from a cmd window, not as an administrator, it runs with no problems.
Task Scheduler is set to run as a user that has administrator rights
What am I doing wrong
ASKER
It's the user running in CMD the same as task? - Yes
Is it using a mapped drive letter? - No
Or, the administrator needs to authenticate first. - The user id being used in Task Scheduler is an administrator
Is it using a mapped drive letter? - No
Or, the administrator needs to authenticate first. - The user id being used in Task Scheduler is an administrator
Make a similar task which runs as same administrator:
Is the output successful? If not, that administrator is having problem reading that directory, i.e. may not have correct permissions
cmd.exe /c dir "\\servername\source directory">"%temp%\result.txt"
Review result.txt.Is the output successful? If not, that administrator is having problem reading that directory, i.e. may not have correct permissions
ASKER
I couldn't get the cmd to run, it said the computer could not be found
I also found that the disk is a virtual disk
I also found that the disk is a virtual disk
Please show your setup for this task. Mainly, the General, Triggers, and Actions tabs. This will expedite help.
ASKER
Please post code of robodrive.vbs
ASKER
Here you go
roboDrive.txt
roboDrive.txt
Questions...
1. Under General, is user account D9HG2961\DeeDee a local account?
2. Is S: a network drive letter?
1. Under General, is user account D9HG2961\DeeDee a local account?
2. Is S: a network drive letter?
ASKER
D9HG2961\DeeDee Is a little local account
The drive is a virtual drive
The drive is a virtual drive
Since D9HG2961\DeeDee is a local account, it does not have access to virtual drive S:.
You need to use the account and credentials used to access the virtual drive.
In your vbs, add lines like this to the top of your script:
You need to use the account and credentials used to access the virtual drive.
In your vbs, add lines like this to the top of your script:
' Map virtual or network drive letter
Set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive "S:" , "\\WhateverServerName\WhateverShareName"
' Rest of code...
Set oShell=WScript.CreateObject("WScript.Shell")
'*************** Power Shell
REM Set Source Folder
strSource = Chr(34) & "S:" & Chr(34)
REM Set Destination Folder
strTarget = Chr(34) & "C:\backup" & Chr(34)
strParms = " /e /xo /R:5 /W:5 /LOG+:" & Chr(34) & "C:\bat\logs\bat.log" & Chr(34)
oShell.Run "robocopy " & strSource & " " & strTarget & strParms
ASKER
That is the account that has access to the drive
That user uses the data on that drive exclusively all day
Why would the script work from the cmd line and not from task scheduler if there’s an access problem
That user uses the data on that drive exclusively all day
Why would the script work from the cmd line and not from task scheduler if there’s an access problem
> Why would the script work from the cmd line and not from task scheduler
IDK.
Try this... Make a new scheduled task.
General:
- When running the task, user user account... ( Make sure it matches the user as the robocopy task ). If not, pick 'Change user or group' button to adjust it.
Triggers:
- One time. Set a time a few minutes earlier than what it shows so it doesn't run. You'll run it manually later.
Actions:
- Start a program: cmd. Add arguments: /k
OK to save it.
Manually run it. This opens a CMD window.
Type dir s:\
Can you see the files in that drive?
You can even run the script to see if it works via cscript c:\bat\robodrive.vbs
IDK.
Try this... Make a new scheduled task.
General:
- When running the task, user user account... ( Make sure it matches the user as the robocopy task ). If not, pick 'Change user or group' button to adjust it.
Triggers:
- One time. Set a time a few minutes earlier than what it shows so it doesn't run. You'll run it manually later.
Actions:
- Start a program: cmd. Add arguments: /k
OK to save it.
Manually run it. This opens a CMD window.
Type dir s:\
Can you see the files in that drive?
You can even run the script to see if it works via cscript c:\bat\robodrive.vbs
ASKER
Both run with no errors
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Is it using a mapped drive letter? If so, you may need to map the drive in vbs. Or, don't use drive letter.
Or, the administrator needs to authenticate first.