Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script that reads its own file name

Status
Not open for further replies.

puforee

Technical User
Oct 6, 2006
741
US
I am looking for a VB script (vbs) that will open a file based on its own file name.

Like I would name the vbs file 3600. Inside, the scrip would read its own file name and set it as a constant. Then I could open a fliel like (the constant)&.pdf.

The total script will be more complicated but I need the script to read its own file name to be able to manipulate other files of differnt types but with the same file name.

I will provide an example if this is confusing.
 
WScript.Echo WScript.ScriptName

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
dm4ever.

Thanks - I am a bit of a novice.

Can you show me a little script using this.

Lets say Dim FN

FN = WScript.Echo WScript.ScripName

MsgBox FN

I am sure I have this messed up....please help.
 
Dim scriptName : scriptName = WScript.ScriptName
MsgBox scriptName

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
Thank you,

I really appreciate the help.

I will revise my main script to see if this works. (I assume it will)

 
Ah...one further question. I set the name to test.vbs and the message box said test.vbs---Great. Can I get rid of the .vbs?
 
Dim scriptName : scriptName = WScript.ScriptName
MsgBox Left(scriptName, Len(scriptName) - 4)

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
Great...boy I sure missed that one. Duh!!!

I am set to go now. Thanks,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top