Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VBScript not working on 2008 R2 - Permission Denied

Posted on 2014-04-24
14
Medium Priority
?
2,083 Views
Last Modified: 2014-06-28
Hello All, I will make this quick. I had a script that was running on my old 2008 server that cleaned a public scans folder of files greater then 2 days old. We since migrated the server to a 2008 R2 server and noticed this script was not function any longer with the error at line 18 char 1 permission denied. The line contains the argument "objFile.delete". I have attached the script for review as well.
Any ideas why this stopped working?
Folderclean.vbs
0
Comment
Question by:CKabs
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
  • 3
  • +1
14 Comments
 
LVL 35

Expert Comment

by:ste5an
ID: 40021454
Permission denied (Error 5 imho) simply means that the account under which this script is running has not the NTFS permissions to delete files. Or after looking at your script reading one of the folders. Use AccessEnum and scan the folder hierarchy. Run it under the same account as your script.
0
 
LVL 1

Author Comment

by:CKabs
ID: 40023074
Hey ste5an, I am a domain admin. And this folder has read/write privilege for that group. I also confirmed this in AccessEnum. This is why I am so boggled by this...
0
 
LVL 35

Expert Comment

by:ste5an
ID: 40023330
What type of "scan"? Are there any open handles on those files? Maybe an exclusive one?
0
More Than Just A Video Library

Train for your certification. Learn the latest DevOps tools. Grow your skillset to do better work.

At Linux Academy, we release new training modules every week so you'll always be up to date on the latest tech.

 
LVL 1

Author Comment

by:CKabs
ID: 40023475
A scan from a copy machine. There are no open handles on the files. Keep in mind, this script worked without issue prior to migrating to our new 2008 R2 server. No permissions changed during the migration.
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 40024415
Try running the script from an elevated command prompt by running cmd.exe "As Administrator" in the right-click menu.  Run the script with
cscript C:\Scripts\FolderClean.vbs

and see if you still get the error.

Regards,

Rob.
0
 
LVL 1

Author Comment

by:CKabs
ID: 40024470
Actually I had not tried running it from CMD. I tried that without elevation and it worked. Great! But what the heck is that about? Why would it work from CMD but not just by running the script. UAC is disabled BTW. Maybe you can give an explanation of why that worked...
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 40024491
Not entirely sure....unless it has something to do with the F drive mapping for your user session?  If it's a scheduled task that you are running, chances are that the user running the task does not have the F drive mapped.  You could try changing the F:\Public Scans reference to \\server\share\Public Scans and see if that helps.

Rob.
0
 
LVL 12

Expert Comment

by:jkaios
ID: 40026499
That's a Windows OS security issue.  No modification is needed for your script, just change permission on folder "F:\Public Scans" and your script should work fine.

- right click on folder "F:\Public Scans"
- select "Properties"
- click on the Security tab
- click Edit... button
- click Add... button
- enter "Everyone" and click OK
- select Everyone and ensure the Modify and Write permission are checked under Allow
- click Apply
- click OK

Besides the built-in "Everyone" user group, you can also designate a specific user to run your script and then add that specific user using the above procedures.
0
 
LVL 12

Expert Comment

by:jkaios
ID: 40026505
...I agree with Rob...if drive "F:" is NOT a local drive, then the problem could simply be that the drive is not being mapped the moment that the script is running.  And in Windows, drive mappings are stored in each user profile (not accessible to all users on the same machine).
0
 
LVL 1

Author Comment

by:CKabs
ID: 40027943
The script I posted was my original version where the "F" drive was local. The script I have on the migrated server reflects the new drive letter. Regardless, I reviewed the permissions numerous times to be sure I wasn't missing anything. I wasn't. They are correct. The script seems to run just fine from command line without making any permissions changes. Is this something that changed in 2008 R2? That maybe you cant run vbs files/scripts direct. They must be run through CMD? That seems silly.
0
 
LVL 12

Accepted Solution

by:
jkaios earned 500 total points
ID: 40028117
How exactly does the script run?  Does it run automatically when the OS starts?
 - from the Startup folder in the Start Menu?
 - from Run in registry...HKLM\Software\Microsoft\Windows\CurrentVersion...?
 - from Schedule Task?
 - from a Service?
0
 
LVL 65

Assisted Solution

by:RobSampson
RobSampson earned 500 total points
ID: 40028395
I would assume that you're running it from a scheduled task.  Is the location you are running the script from a "local" fixed drive, and not a mapped driver to another server?  If it's local, it shouldn't be a problem running by double-clicking.  If it's on a network location, as jkaios has mentioned, it may due to the file being "blocked" from the network location, until you approve it.

In either case, if you run the script explicitly stating the scripting engine, using
C:\Windows\SysWOW64\cscript.exe F:\Scripts\FolderClean.vbs
or
C:\Windows\SysWOW64\wscript.exe F:\Scripts\FolderClean.vbs

it shouldn't have a problem.

Rob.
0
 
LVL 1

Author Comment

by:CKabs
ID: 40032173
It is running from a local drive. Mysteriously this script is working when I double click it now. I have zero explanation for this. No changes were made that haven't been tested before posting. I am going to reconfig this in task scheduler and see if it works. Ill post back in a few days when I confirm this is working again and award points. Thanks for all the comments folks.
0
 
LVL 1

Author Closing Comment

by:CKabs
ID: 40164485
Unfortunately none of the comments led me in the direction of an explanation for this. However I reward points for effort. Thanks for the assistance on this experts!
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
This tutorial will show how to configure a single USB drive with a separate folder for each day of the week. This will allow each of the backups to be kept separate preventing the previous day’s backup from being overwritten. The USB drive must be s…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question