objFile.Copy making folder read only?
- From: "Shamalama1650" <Shamalama1650@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 28 Jul 2005 11:21:03 -0700
I finally got this script working but now I am getting a 'Permission Denied"
on the folder Im copying images to after I run it once. I can reboot and it
will run for one time again. I even went to the parent folder, unchecked read
only, and applied to all child objects but it keeps going back to read only
and my script is failing with the 'permission denied'. I am also getting
propted for one username after there are no more pictures. Any thoughts? Here
it is:
'This should pull all pictures from camera (2 of each user),
'prompt for names in order of photo taken, Save pictures to
'a local directory as promptedusername01.jpg..promptedusername02.jpg,
'delete files on camera, call CropAndGray.bat, and then
'send a link to PromptedUserName@xxxxxxxxxx
Dim objFso
Dim objFile
Dim objFolder
Dim strSourcePath
Dim objTextFile
Const ForAppending = 8
Const DeleteReadOnly = TRUE
'The source will be changed to the camera
'drive once the script is working
strSourcePath = "C:\photo\camera"
Set objFso = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFso.GetFolder(strSourcePath)
'This will contain all the usernames
'and will be used for the send mail portion later
Set objTextFile = objFSO.OpenTextFile _
("c:\photo\users.txt", ForAppending, True)
'Loop through the pictures
For Each objFile In objFolder.Files
' If count = 0 or 2 will prompt for user name otherwise
' will save photo to output folder and increment count
If i = 0 Then
strUsername = InputBox("Please enter a new username")
objTextFile.WriteLine(strUsername)
i = 1
Elseif i = 1 Then
i = 2
Elseif i = 2 Then
strUsername = InputBox("Please enter a new username")
objTextFile.WriteLine(strUsername)
i = 1
End If
'Copy the file to a different folder and rename it using the username
'and employee picture count
objFile.Copy "C:\Photo\originals\" & strUsername & "0" & i & ".jpg", True
Next
objTextFile.Close
objFSO.DeleteFile("C:\photo\camera\*.jpg"), DeleteReadOnly
'Call CropandGrey.bat to edit the photos
Dim oShell
set oshell=createobject("Wscript.shell")
oShell.Run "C:\photo\CropAndGrey.bat"
set oShell = Nothing
'From Demonstration script that uses CDO to send email
'from a computer where the SMTP Service has not been installed.
'Sends a link to each UserName that was entered at "UserName"
'Prompt using a "for each" from users.txt. Any help in this area would
'be apprciated too.
'Set objEmail = CreateObject("CDO.Message")
'objEmail.From = "PictureMan@xxxxxxxxxx"
'objEmail.To = "PromptedUserName@xxxxxxxxxx"
'objEmail.Subject = "Choose your picture!"
'objEmail.Textbody = "\\server\picturechooser.htm"
'objEmail.Configuration.Fields.Item _
' ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'objEmail.Configuration.Fields.Item _
' ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _
' "mail.domain.com"
'objEmail.Configuration.Fields.Item _
' ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
'objEmail.Configuration.Fields.Update
'objEmail.Send
'objFSO.DeleteFile("C:\photo\users.txt"), DeleteReadOnly
.
- Prev by Date: WshRemote Exit Code
- Next by Date: Re: Error: Expected statement?
- Previous by thread: WshRemote Exit Code
- Next by thread: Installing a New Font Using A Startup Script
- Index(es):
Relevant Pages
|