ActiveX Script for scheduled job - FileMove, FileCopy, FileDelete

Hi Experts,

i have two questions, maybe you can give me a help
1. Do you know with which software i can debug activex-Scripts
2.  In the script below i want the name of the file without extension, and I think the handling of the file.type works not right

Source1 = "\\cdcna002\TECSNOP\" & Left(file.Name, Len(file.Name) - 4) & "\Send\Send_Archiv\"
If file.Type = "AGO File" ....
if file.Type = "Winzip File" ...

Nothing happen, if i run the code. On the other hand, if i run the code in VBA it works quit good.

Do you have any ideas? Thanks in advance


Sub FileOP
Dim myfso, myf2, myf1
Dim strMonat, strTag, strJetzt
Dim file, file1
Dim Source1, Destination, Dest2, Source

Set myfso = CreateObject("Scripting.FileSystemObject")
Set myf2 = myfso.GetFolder("\\cdcna002\TECSNOP\GoListe\Go_archiv\")


Destination = "\\mcwwtkdksql\NOR_TEMP\"
Dest2 = "\\oslwdds01\Ixos_Archive\"
Source = "\\cdcna002\TECSNOP\GoListe\Go_archiv\"


If Len(Month(Date)) = 1 Then
    strMonat = "0" & Month(Date)
     Else
     strMonat = Month(Date)
End If

If Len(Day(Date)) = 1 Then
     strTag = "0" & Day(Date)
     Else
     strTag = Day(Date)
End If

strJetzt = Right(Year(Date), 2) & "-" & strMonat & "-" & strTag
If myfso.FolderExists(Destination & strJetzt) Then
Else
myfso.CreateFolder Destination & strJetzt
End If
If myfso.FolderExists(Dest2 & strJetzt) Then
Else
myfso.CreateFolder Dest2 & strJetzt
End If


For Each file In myf2.Files
           
    If file.Type = "AGO File" Then
       Source1 = "\\cdcna002\TECSNOP\" & Left(file.Name, Len(file.Name) - 4) & "\Send\Send_Archiv\"
                 
       Set myf1 = myfso.GetFolder(Source1)
           For Each file1 In myf1.Files
               If file1.Type = "Winzip File" Then
                  myfso.CopyFile Source1 & file1.Name, Dest2 & strJetzt & "\" & file1.Name
                  myfso.CopyFile Source1 & file1.Name, Destination & strJetzt & "\" & file1.Name
                  myfso.DeleteFile Source1 & file1.Name
                  myfso.DeleteFile Source & file.name
               End If

           Next

     
     
               
    End If
                                               
Next

end sub
schulzekAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SashPCommented:
Hi schulzek

Microsoft Script Debugger http://www.microsoft.com/downloads/details.aspx?FamilyID=2f465be0-94fd-4569-b3c4-dffdf19ccd99&displaylang=en


And perhaps you should be posting this question a different group. :)
Cheers Sash
0
SashPCommented:
schulzek,

You want to be using the GetExtensionName of the FileSystemObject http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/jsmthgetextensionname.asp

Cheers Sash
0
SashPCommented:
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

rdrunnerCommented:
Hello

Destination = "\\mcwwtkdksql\NOR_TEMP\"
Dest2 = "\\oslwdds01\Ixos_Archive\"
Source = "\\cdcna002\TECSNOP\GoListe\Go_archiv\"

If i look at those lines i can see the you are trying to access network shares. You need to make sure that the Server-Agent is using an account that has sufficient rights to access those shares. If you are using the default (local system) then you wont be able to access those files since the local system account is (most likely) not allowed to do anything on the network. So you wont be able to access any files there
0
schulzekAuthor Commented:
Thanks for the quick response

To rdrunner
i have an account with the rights to access to the shares

Klaus
0
rdrunnerCommented:
YSes.. I know that YOU have the account.. You said YOU can run the Script without problems. But when its run from the SQL-Server agent it wont be run with YOUR account. It will be run with the account thats listed under the SQL-Serveragent

Rightclick on the SQL-Serveragent and check the properties. There should be an account entry on top of the property page. This account will be used when the SQL-Server starts your script in the sceduler. You need to make sure that THIS account has access to the shares you use.
0
schulzekAuthor Commented:
Answer to rdrunner.
Thank you for your request. I also tought about that point.
The error occours in that line:
'If file1.Type = "Winzip File" Then'
I wrote "WinZip File" ("Z"  as a capital letter) and now it works. I dont unterstand this point.

best regards
Klaus
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.