473,887 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Microsoft Scripting Runtime #3

ADezii
8,834 Recognized Expert Expert
This is the 3rd in a series of Tips dealing specifically with the Microsoft Scripting Runtime Library. In this Tip, we'll show you how to return specific Properties relating to Files, as well as various Methods to Copy, Move, and Delete them. The code is self explanatory, so I'll jump right in:
Expand|Select|Wrap|Line Numbers
  1. Dim fso As FileSystemObject, fil As File
  2. 'Set fso = New Scripting.FileSystemObject    OR
  3.  
  4. Set fso = CreateObject("Scripting.FileSystemObject")
  5.  
  6. Set fil = fso.GetFile("C:\Windows\System32\Calc.exe")
  7.  
  8. Debug.Print "File Created on: " & fil.DateCreated
  9. Debug.Print "File Size: " & FormatNumber(fil.Size, 0) & " bytes"
  10. Debug.Print "File Drive: " & fil.Drive
  11. Debug.Print "File Name: " & fil.Name    'OR
  12. Debug.Print "File Name: " & fso.getFileName(fil)
  13. Debug.Print "File Last Modified: " & fil.DateLastModified
  14. Debug.Print "File Last Accessed: " & fil.DateLastAccessed
  15. Debug.Print "File Parent Folder: " & fil.ParentFolder
  16. Debug.Print "File Type: " & fil.Type
  17. Debug.Print "File Path: " & fil.path
  18. Debug.Print "File Short Name: " & fil.ShortName
  19. Debug.Print "File Short Path: " & fil.ShortPath
  20. Debug.Print "File Extension: " & fso.GetExtensionName(fil)
  21. Debug.Print "File Version: " & fso.GetFileVersion(fil)
  22.  
  23. 'To Copy a File (Copy C:\Windows\System32\Calc.exe ==> C:\Dell\Copy.exe)
  24. fil.Copy ("C:\Dell\Copy.exe")       'OR
  25. fso.CopyFile "C:\Windows\System32\Calc.exe", "C:\Dell\Copy.exe", True
  26.  
  27. 'To Delete a File (C:\Dell\IP.txt)
  28. Set fil = fso.GetFile("C:\Dell\IP.txt")
  29. fil.Delete True     'OR
  30. fso.DeleteFile "C:\Dell\IP.txt", True
  31.  
  32. 'To Move a File (C:\Dell\Move_From.txt ==> C:\Test\Move_To.txt
  33. Set fil = fso.GetFile("C:\Dell\Move_From.txt")
  34. fil.Move "C:\Test\Move_To.txt"      'OR
  35. fso.MoveFile "C:\Dell\Move_From.txt", "C:\Test\Move_To.txt"
File Properties OUTPUT:
Expand|Select|Wrap|Line Numbers
  1. File Created on: 9/11/2007 2:18:54 PM
  2. File Size: 114,688 bytes
  3. File Drive: C:
  4. File Name: calc.exe
  5. File Name: calc.exe
  6. File Last Modified: 8/4/2004 5:00:00 AM
  7. File Last Accessed: 2/15/2008 11:30:31 AM
  8. File Parent Folder: C:\WINDOWS\system32
  9. File Type: Application
  10. File Path: C:\WINDOWS\system32\calc.exe
  11. File Short Name: Calc.exe
  12. File Short Path: C:\Windows\System32\Calc.exe
  13. File Extension: exe
  14. File Version: 5.1.2600.0
Feb 15 '08 #1
0 5425

Sign in to post your reply or Sign up for a free account.

Similar topics

1
4133
by: MatthewRoberts | last post by:
Howdy All, I am having difficulty with two-way communication across AppDomains in an attempt to dynamically script applications. Everything works as expected, except when using ByRef parameters. The below explanation is lengthy, but well worth the read. If you can help me, I'd gladly share this code which has greatly helped my development of extensible applications.
0
1579
by: fiona | last post by:
Catalyst Releases Scripting Editions of SocketTools Client and server-side development for Active Server Pages and PHP. Yucca Valley, CA, May 25, 2005 - Catalyst Development Corp (www.catalyst.com) - with over 10 years experience developing Internet components announced that Scripting and Secure Scripting Editions have been added to the SocketTools family of products. The Scripting Editions were designed specifically for client and...
17
4219
by: Karl Irvin | last post by:
To use the Textstream object, I had to set a Reference to the Microsoft Scripting Runtime. This works good with A2000 Is the Scripting Runtime included with A2002 and A2003 so the Reference won't be broken when my app is opened with those versions. Also is the Scripting Runtime included as part of the A2000 Runtime Engine which some of my customers use.
1
2346
by: Karl Irvin | last post by:
To use the Textstream object, I had to set a Reference to the Microsoft Scripting Runtime. This works good with A2000 Is the Scripting Runtime included with A2002 and A2003 so the Reference won't be broken when my app is opened with those versions. Also is the Scripting Runtime included as part of the A2000 Runtime Engine which some of my customers use.
14
2334
by: frostalicious | last post by:
Used VB.NET (on my client PC) to convert VB6 executable to .NET executable. Placed the .exe file on a network drive on my server. From client, ran .NET Wizards "Trust an Assembly" to make the .exe (on the network drive, on the server) "Full Trust." From the client, double-click on the ..exe (on the network drive, on the server) and it runs fine. So far, so good, but... On the server, where I've installed not VB.NET but .NET
1
1013
by: PaulieS | last post by:
Hi all. Am migrating a customer from IIS5 on W2K server to IIS6 on W2K3. Zipped all the websites and unzipped them to the identical locations on new server. Used IISMT to migrate metabase. Got this error when I tried to run a very basic page... code: <%@ LANGUAGE=vbscript %> <%
7
8870
ADezii
by: ADezii | last post by:
The next series of Tips will involve the Microsoft Scripting Runtime Library (Scrrun.dll). This Library is, in my humble opinion, one of the most useful and practical Libraries ever created. With the Scripting Runtime Library, you can retrieve information related to Drives, Folders, Files, and Text Files and set/retrieve certain Attributes of Drives, Folders, Files, and Text Files. Through Methods exposed by this Library, you can also manipulate...
0
5163
ADezii
by: ADezii | last post by:
This is the 2nd Tip in a series of Tips on the Microsoft Scripting Runtime Library. The 1st Tip related to Drives, while this Tip will concentrate on the Folders (Directories) in your PC and various methods to retrieve information from and how to manipulate them. The code should be self explanatory and basically documents itself. Should there be any questions related to this Topic, please feel free to ask. 'Accessing Folder Properties Dim...
0
4471
ADezii
by: ADezii | last post by:
This is the last in a series of Tips involving the Microsoft Scripting Runtime Library and deals with creating, opening, writing to, reading from, and closing Text Files via this Library. At this time, the Scripting Library cannot deal with the opening and manipulation of Files in Binary Mode, so we will only demonstrate this functionality as it relates to Text Files. The code is fairly straightforward and sparsely commented, so I will not bore...
0
9957
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11173
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10770
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10875
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10432
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7988
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4632
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4238
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3245
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.