Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

File manipulation in VB express


  • Please log in to reply

#1
dsenette

dsenette

    Je suis Napoléon!

  • Administrator
  • 26,046 posts
  • MVP
i've got a small program that i wrote in vb express (it's free..give me a break) to help me manage systems on a secondary network....the program has a bunch of tabs that let you restart or shutdown all the pcs on the network (or one at a time), reload a proprietary software package on all of the pcs (or one at a time), initiate a VNC session with each pc, and the last tab initiates a batch file that grabs the logs from the software on the pcs and copies it over to the server into a folder with the same name as the pc (i.e. pc1's log goes into the pc1 folder)...what i'm wanting is the ability to have VB look at the folder...and if a log already exists....to rename the file with say...that days date...or possibly for it to rename the file as soon as it copies it over the first time...that way the date is more accurate..

i know that i could use the batch file that i'm copying with (simple xcopy batch...executed on the pc via psexec from the server) to name the file by date (simple %date% command) but the issue there is that i'd have to change the date format on ALL the pcs on the network to be in a dd-mm-yyyy format instead of dd/mm/yyyy format...not a fun proposition....

i'm looking for a method within vb to automatically change the file name after it's copied to the server from logfile.log (or whatever) to logfile-dd-mm-yyyy.log or something to that effect.
  • 0

Advertisements


#2
IO-error

IO-error

    Member

  • Member
  • PipPipPip
  • 276 posts
Will code in VBS be a problem for you?
If you understand VBS, you can probably code it in VB yourself.

strComputer = "."
Set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colClass = objWMI.ExecQuery("Select * from Win32_LocalTime",,48)
Set FSO = CreateObject("Scripting.FileSystemObject")
Set update = FSO.OpenTextFile("oldname.txt", 8, True)
For each objClass in colClass
If fso.FileExists("C:\oldname.txt") Then
If Len(objClass.Minute) = 1 Then
update.Writeline (""& objClass.Hour &":0" & objClass.Minute &" " & WeekdayName(Weekday(Date)) &" " & objClass.Day &"-" &month(date) &"-" & year(date))
Else
update.Writeline (""& objClass.Hour &":" & objClass.Minute &" " & WeekdayName(Weekday(Date)) &" " & objClass.Day &"-" &month(date) &"-" & year(date))
End If
fso.CopyFile "c:\oldname.txt", "c:\newname.txt"
End If
Next

I hope I gave you a pointer in the right direction, but I don't know how close this comes to the VB language. I do know it's working in VBS so it could be a good example for you.

Edited by IO-error, 07 February 2007 - 02:58 AM.

  • 0

#3
dsenette

dsenette

    Je suis Napoléon!

  • Topic Starter
  • Administrator
  • 26,046 posts
  • MVP
i'll see what it does..
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP