Re: Change the way a file name is displayed (remove the c:\ and change to http)

From: Joshua C. Clark (Josh_at_NetworkMedics.Com)
Date: 09/13/04


Date: Mon, 13 Sep 2004 14:13:31 -0400

When I use the new code I get,

http://small\image.jpg instead of http://small/image.jgp

Any ideas why, here is my NEW code with your changes, again thanks!

' on error resume next

strComputer = "."
Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adUseClient = 3
Set objWMIService = GetObject("winmgmts:" &
"{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colFiles = objWMIService.ExecQuery("Select * from CIM_DataFile where
Path = '\\small\\'")

For Each objFile in colFiles

Set objConnection = CreateObject("ADODB.Connection")
Set objRecordset = CreateObject("ADODB.Recordset")
objConnection.Open "DSN=Filename;"
objRecordset.CursorLocation = adUseClient
objRecordset.Open "SELECT * FROM Filename" , objConnection, adOpenStatic,
adLockOptimistic
objRecordset.AddNew
objRecordset("Filename") = Replace(objFile.Name, "c:\", "http://", 1, -1,
vbTextCompare)
objRecordset.Update

Next

objRecordset.Close
objConnection.Close

"Joshua C. Clark" <Josh@NetworkMedics.Com> wrote in message
news:ePkRN$amEHA.828@TK2MSFTNGP10.phx.gbl...
> Thats it, works beutifully, thank you!
>
>
> "Torgeir Bakken (MVP)" <Torgeir.Bakken-spam@hydro.com> wrote in message
> news:%23iNW0vamEHA.1904@TK2MSFTNGP09.phx.gbl...
> > Joshua C. Clark wrote:
> >
> > > What I would like to do in my script is change the c:\ to http://
before
> it
> > > is written in my database, any help would be great, thanks!
> > >
> > > ' on error resume next
> > >
> > > strComputer = "."
> > > Const adOpenStatic = 3
> > > Const adLockOptimistic = 3
> > > Const adUseClient = 3
> > > Set objWMIService = GetObject("winmgmts:" &
> > > "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
> > > Set colFiles = objWMIService.ExecQuery("Select * from CIM_DataFile
where
> > > Path = '\\small\\'")
> > >
> > > For Each objFile in colFiles
> > >
> > > Set objConnection = CreateObject("ADODB.Connection")
> > > Set objRecordset = CreateObject("ADODB.Recordset")
> > > objConnection.Open "DSN=Filename;"
> > > objRecordset.CursorLocation = adUseClient
> > > objRecordset.Open "SELECT * FROM Filename" , objConnection,
> adOpenStatic,
> > > adLockOptimistic
> > > objRecordset.AddNew
> > > objRecordset("Filename") = objFile.Name
> > Hi
> >
> > Replace the line above with this and see if it gives you what you want:
> >
> > objRecordset("Filename") = _
> > Replace(objFile.Name, "c:\", "http://", 1, -1, vbTextCompare)
> >
> >
> > --
> > torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
> > Administration scripting examples and an ONLINE version of
> > the 1328 page Scripting Guide:
> > http://www.microsoft.com/technet/scriptcenter/default.mspx
>
>



Relevant Pages

  • Change the way a file name is displayed (remove the c: and change to http)
    ... Const adLockOptimistic = 3 ... Const adUseClient = 3 ... Set colFiles = objWMIService.ExecQuery("Select * from CIM_DataFile where ... Set objConnection = CreateObject ...
    (microsoft.public.scripting.vbscript)
  • Re: Write to file
    ... Dim strFile, objFSO, objFile ... Const OpenAsASCII = 0 ... Set objFile = objFSO.OpenTextFile(strFile, _ ... Microsoft MVP Scripting and ADSI ...
    (microsoft.public.scripting.vbscript)
  • Re: Help Splitting a String
    ... Const ADS_PROPERTY_DELETE = 4 ... Set objConnection = CreateObject ... MsgBox homedir - This bit is OK ... MsgBox newservername ...
    (microsoft.public.scripting.vbscript)
  • Help Splitting a String
    ... Const ADS_PROPERTY_DELETE = 4 ... Set objConnection = CreateObject ... MsgBox homedir - This bit is OK ... MsgBox newservername ...
    (microsoft.public.scripting.vbscript)
  • Re: FileSystemObject: Invalid procedure call or argument Error 800A00
    ... Const ForReading = 1 ... ' Instantiate the File System Object ... ' Create an archive output log file for all executions of the script ... Set colFiles = objFolder.Files ...
    (microsoft.public.scripting.vbscript)