[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

ActiveX Script for scheduled job - FileMove, FileCopy, FileDelete

Posted on 2004-11-04
7
Medium Priority
?
451 Views
Last Modified: 2011-10-03
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
0
Comment
Question by:schulzek
  • 3
  • 2
  • 2
7 Comments
 
LVL 8

Expert Comment

by:SashP
ID: 12491160
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
 
LVL 8

Expert Comment

by:SashP
ID: 12491182
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
 
LVL 8

Accepted Solution

by:
SashP earned 750 total points
ID: 12491194
0
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
LVL 11

Expert Comment

by:rdrunner
ID: 12491729
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
 

Author Comment

by:schulzek
ID: 12492812
Thanks for the quick response

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

Klaus
0
 
LVL 11

Expert Comment

by:rdrunner
ID: 12493302
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
 

Author Comment

by:schulzek
ID: 12521792
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

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
Suggested Courses

872 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