Results 1 to 3 of 3
  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2013

    WScript.Arguments aren't working 100% of the time : HTML + VBScript

    Hello all,
    This is my first post. I have looked through a number of posts but haven't found anything like my issue. I'm still fairly new to the vbscript world so any help is GREATLY appreciated.

    I am trying to pass a value in from an HTML file (code below). For some reason still unknown to me the Args(0) works when I am using the FSO.CreateTextFile(Args(0) & "mytext.txt", True) command but doesn't work for FSO.CopyFile Args(0), "C:\temp\myfolder\". My goal is to pass in a whole file path "C:\something\mytextfile.txt" from the HTML file and then copy the file off to another folder using vbscript.

    I have tried to see the value of Args(0) using msgboxs and printing it out to a cmd window but it appears as nothing. I am at my wits end and ready to jump off the bridge. Please can someone explain to me what I'm doing wrong? What do I need to do to pass in an argument that has the filepath?

    Thank you, Thank you, Thank you,


    I have a vbs file:
    Option Explicit
    Dim FSO, Args, tsOut

    Set FSO = CreateObject("Scripting.FileSystemObject")
    Set Args = WScript.Arguments
    Set tsOut = FSO.CreateTextFile(Args(0) & "mytext.txt", True)
    tsOut.WriteLine CStr(Now)

    FSO.CopyFile(Args(0) & "mytext.txt, "C:\Users\cstriefel\Desktop\Test\Test2\")

    MsgBox Args(0), vbOkOnly, WScript.ScriptName

    Set tsOut = Nothing
    Set Args = Nothing
    Set FSO = Nothing

    And an HTML file:
    <script language=vbscript>
    Option Explicit
    Dim WSHShell
    Dim Path

    Sub SetPath()
    Dim PathParts, X

    PathParts = Split(Mid(window.location.pathname, 2), "%")
    For X = 1 To UBound(PathParts)
    PathParts(X) = _
    Chr(CInt("&H" & Left(PathParts(X), 2))) _
    & Mid(PathParts(X), 3)
    Path = Join(PathParts, "")
    Path = Left(Path, InStrRev(Path, "\"))
    End Sub

    Sub btnWScript_onclick()
    'Run: wscript "{path}test2.vbs" "{path}"
    WSHShell.Run _
    "wscript """ & Path & "test2.vbs"" """ & Path2 & """"
    window.status = "Script has been run via WScript"
    End Sub

    Sub window_onload()
    Set WSHShell = CreateObject("WScript.Shell")
    End Sub

    Sub window_onunload()
    Set WSHShell = Nothing
    End Sub
    <input type=button id=btnWScript value="Use WScript">

  2. #2

    Thread Starter
    New Member
    Join Date
    Sep 2013

    Re: WScript.Arguments aren't working 100% of the time : HTML + VBScript

    Awesome answers! Thanks everyone!

  3. #3
    PowerPoster abhijit's Avatar
    Join Date
    Jun 1999
    Chit Chat Forum.

    Re: WScript.Arguments aren't working 100% of the time : HTML + VBScript

    What happens when you fire SETPATH()? My thought is that your PATH variable is not getting set correctly.
    Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
    save a blobFileStreamDataTable To Text Filemy blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts


Click Here to Expand Forum to Full Width

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.