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
objRecordset.Update

Next

objRecordset.Close
objConnection.Close

Re: Change the way a file name is displayed (remove the c:\ and change by Torgeir

Torgeir
Mon Sep 13 11:08:42 CDT 2004

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

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

Joshua
Mon Sep 13 11:36:17 CDT 2004

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



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

Joshua
Mon Sep 13 13:13:31 CDT 2004

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
>
>



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

Michael
Mon Sep 13 19:04:51 CDT 2004

Joshua C. Clark wrote:
> 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!
>

Do 2 separate Replace calls...

filename = objFile.Name
filename = Replace(filename, "c:\", "http://", 1, -1, vbTextCompare)
filename = Replace(filename, "\", "/", 1, -1, vbTextCompare)
objRecordset("Filename") = fname

--
Michael Harris
Microsoft.MVP.Scripting
Sammamish WA US

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

Joshua
Tue Sep 14 08:22:27 CDT 2004

Awesome thanks!

"Michael Harris (MVP)" <mikhar at mvps dot org> wrote in message
news:Odrj25emEHA.748@TK2MSFTNGP15.phx.gbl...
> Joshua C. Clark wrote:
> > 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!
> >
>
> Do 2 separate Replace calls...
>
> filename = objFile.Name
> filename = Replace(filename, "c:\", "http://", 1, -1, vbTextCompare)
> filename = Replace(filename, "\", "/", 1, -1, vbTextCompare)
> objRecordset("Filename") = fname
>
> --
> Michael Harris
> Microsoft.MVP.Scripting
> Sammamish WA US



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

Joshua
Tue Sep 14 08:43:49 CDT 2004

Works beautifully, thank you so much!!


"Joshua C. Clark" <Josh@NetworkMedics.Com> wrote in message
news:eLSdj3lmEHA.2096@TK2MSFTNGP15.phx.gbl...
> Awesome thanks!
>
> "Michael Harris (MVP)" <mikhar at mvps dot org> wrote in message
> news:Odrj25emEHA.748@TK2MSFTNGP15.phx.gbl...
> > Joshua C. Clark wrote:
> > > 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!
> > >
> >
> > Do 2 separate Replace calls...
> >
> > filename = objFile.Name
> > filename = Replace(filename, "c:\", "http://", 1, -1, vbTextCompare)
> > filename = Replace(filename, "\", "/", 1, -1, vbTextCompare)
> > objRecordset("Filename") = fname
> >
> > --
> > Michael Harris
> > Microsoft.MVP.Scripting
> > Sammamish WA US
>
>