![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Remove characters in a string Hello I've got a string ->ScriptName = wscript.Scriptfullname and the actually path is c:\testfolder\myprogram\script.vbs I'm wanting to remove the script.vbs so I only have c:\testfolder\myprogram\ so I'm removing the last 10 characters or up to the \ How do I do that? |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Remove characters in a string "Gavaskar" <nospam@xxxxxx> wrote in message news:OKp5aQ0$JHA.3432@xxxxxx Quote: > Hello > > I've got a string ->ScriptName = wscript.Scriptfullname and the actually > path is c:\testfolder\myprogram\script.vbs > > I'm wanting to remove the script.vbs so I only have > c:\testfolder\myprogram\ so I'm removing the last 10 characters or up to > the \ > > How do I do that? > 1. Use the "InStrRev" function to determine the position of the right-most backslash. 2. Use the "left" function to extract the leftmost x characters. If unsure how to use these functions, check the examples in the helpfile script56.chm, downloadable from the Microsoft site. |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Remove characters in a string On Jul 7, 4:47*pm, "Gavaskar" <nos...@xxxxxx> wrote: Quote: > Hello > > I've got a string *->ScriptName = wscript.Scriptfullname and the actually > path is c:\testfolder\myprogram\script.vbs > > I'm wanting to remove the script.vbs so I only have c:\testfolder\myprogram\ > so I'm removing the last 10 characters or up to the \ > > How do I do that? actually altering the string, as follows ... sVirtualPath = ScriptName & "\.." or use the FSO GetParentFolderName to strip off the script's name ... sPath = CreateObject("Scripting.FileSystemObject")_ .GetParentFolderName(ScriptName) & "\" or maybe this little trick ... sPath = replace(wsh.ScriptFullName, wsh.ScriptName, "") The first one is functional, but not acceptable for displaying the information. The second is the 'official' way to do it. While the third approach is the one I prefer. Tom Lavedas ************ |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Remove characters in a string Thanks, got it. "Gavaskar" <nospam@xxxxxx> wrote in message news:OKp5aQ0$JHA.3432@xxxxxx Quote: > Hello > > I've got a string ->ScriptName = wscript.Scriptfullname and the actually > path is c:\testfolder\myprogram\script.vbs > > I'm wanting to remove the script.vbs so I only have > c:\testfolder\myprogram\ so I'm removing the last 10 characters or up to > the \ > > How do I do that? > > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Select first 16 characters in a string | PowerShell | |||
| How to Randomize characters in a string | VB Script | |||
| Replacing Multiple Characters In A String | PowerShell | |||
| Capture a string of characters and use as filename. | PowerShell | |||
| Removing characters from a string | PowerShell | |||