How to pass a parameter to vbscript?










1















I have a vbs that runs several tor connections:



proxycount = 3
countries = ""

Set FSO = CreateObject("Scripting.FileSystemObject")
Set f = FSO.OpenTextFile("proxyList.txt", 2, True)

For i=0 To proxycount-1 Step 1

Port = 9000 + i
CPort = 8000 + i

If Not (countries = "") Then
countries = " -ExitNodes " & countries
End If

Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "datator.exe -f datatorrc -SocksPort " & Port & " -ControlPort " & CPort & " -DataDirectory datatorf" & i & countries, 0
WshShell = Null
f.WriteLine "127.0.0.1:" & Port

Next

f.Close


And it works great, but when I'm trying to pass on proxycount as a parameter:
CMD
it stops working:



countries = ""

Set FSO = CreateObject("Scripting.FileSystemObject")
Set f = FSO.OpenTextFile("proxyList.txt", 2, True)

For i=0 To WScript.Arguments(0)-1 Step 1

Port = 9000 + i
CPort = 8000 + i

If Not (countries = "") Then
countries = " -ExitNodes " & countries
End If

Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "datator.exe -f datatorrc -SocksPort " & Port & " -ControlPort " & CPort & " -DataDirectory datatorf" & i & countries, 0
WshShell = Null
f.WriteLine "127.0.0.1:" & Port

Next

f.Close


with error "string 17, symbol 2. Can't find a file" in this line:



WshShell.Run "datator.exe -f datatorrc -SocksPort " & Port & " -ControlPort " & CPort & " -DataDirectory datatorf" & i & countries, 0


What am I doing wrong? I don't know where the error is.










share|improve this question
























  • How do you pass the parameter? If it is a numerical value I believe this should work. It would not work if you pass it as say -10 (with the dash). Also, the line WshShell = Null does not what you want I think, should probably be Set WshShell = Nothing

    – Arno van Boven
    Nov 13 '18 at 21:36











  • @Arno van Boven, it is a numerical value "launch.vbs 2". I added the screenshot in the post.

    – Jooms
    Nov 13 '18 at 21:46











  • It would help if you also included the error you are getting

    – Arno van Boven
    Nov 13 '18 at 21:47











  • @Arno van Boven, string 17, symbol 2. Can't find a file.

    – Jooms
    Nov 13 '18 at 21:52











  • I don't immediately spot a difference. You'd expect a file with a 0 and a 1 if you pass 2 as the argument. (and 0, 1 and 2 in the hardcoded example). Check if you can find a difference in the generated filenames when using the different methods.

    – Arno van Boven
    Nov 13 '18 at 22:13















1















I have a vbs that runs several tor connections:



proxycount = 3
countries = ""

Set FSO = CreateObject("Scripting.FileSystemObject")
Set f = FSO.OpenTextFile("proxyList.txt", 2, True)

For i=0 To proxycount-1 Step 1

Port = 9000 + i
CPort = 8000 + i

If Not (countries = "") Then
countries = " -ExitNodes " & countries
End If

Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "datator.exe -f datatorrc -SocksPort " & Port & " -ControlPort " & CPort & " -DataDirectory datatorf" & i & countries, 0
WshShell = Null
f.WriteLine "127.0.0.1:" & Port

Next

f.Close


And it works great, but when I'm trying to pass on proxycount as a parameter:
CMD
it stops working:



countries = ""

Set FSO = CreateObject("Scripting.FileSystemObject")
Set f = FSO.OpenTextFile("proxyList.txt", 2, True)

For i=0 To WScript.Arguments(0)-1 Step 1

Port = 9000 + i
CPort = 8000 + i

If Not (countries = "") Then
countries = " -ExitNodes " & countries
End If

Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "datator.exe -f datatorrc -SocksPort " & Port & " -ControlPort " & CPort & " -DataDirectory datatorf" & i & countries, 0
WshShell = Null
f.WriteLine "127.0.0.1:" & Port

Next

f.Close


with error "string 17, symbol 2. Can't find a file" in this line:



WshShell.Run "datator.exe -f datatorrc -SocksPort " & Port & " -ControlPort " & CPort & " -DataDirectory datatorf" & i & countries, 0


What am I doing wrong? I don't know where the error is.










share|improve this question
























  • How do you pass the parameter? If it is a numerical value I believe this should work. It would not work if you pass it as say -10 (with the dash). Also, the line WshShell = Null does not what you want I think, should probably be Set WshShell = Nothing

    – Arno van Boven
    Nov 13 '18 at 21:36











  • @Arno van Boven, it is a numerical value "launch.vbs 2". I added the screenshot in the post.

    – Jooms
    Nov 13 '18 at 21:46











  • It would help if you also included the error you are getting

    – Arno van Boven
    Nov 13 '18 at 21:47











  • @Arno van Boven, string 17, symbol 2. Can't find a file.

    – Jooms
    Nov 13 '18 at 21:52











  • I don't immediately spot a difference. You'd expect a file with a 0 and a 1 if you pass 2 as the argument. (and 0, 1 and 2 in the hardcoded example). Check if you can find a difference in the generated filenames when using the different methods.

    – Arno van Boven
    Nov 13 '18 at 22:13













1












1








1


1






I have a vbs that runs several tor connections:



proxycount = 3
countries = ""

Set FSO = CreateObject("Scripting.FileSystemObject")
Set f = FSO.OpenTextFile("proxyList.txt", 2, True)

For i=0 To proxycount-1 Step 1

Port = 9000 + i
CPort = 8000 + i

If Not (countries = "") Then
countries = " -ExitNodes " & countries
End If

Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "datator.exe -f datatorrc -SocksPort " & Port & " -ControlPort " & CPort & " -DataDirectory datatorf" & i & countries, 0
WshShell = Null
f.WriteLine "127.0.0.1:" & Port

Next

f.Close


And it works great, but when I'm trying to pass on proxycount as a parameter:
CMD
it stops working:



countries = ""

Set FSO = CreateObject("Scripting.FileSystemObject")
Set f = FSO.OpenTextFile("proxyList.txt", 2, True)

For i=0 To WScript.Arguments(0)-1 Step 1

Port = 9000 + i
CPort = 8000 + i

If Not (countries = "") Then
countries = " -ExitNodes " & countries
End If

Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "datator.exe -f datatorrc -SocksPort " & Port & " -ControlPort " & CPort & " -DataDirectory datatorf" & i & countries, 0
WshShell = Null
f.WriteLine "127.0.0.1:" & Port

Next

f.Close


with error "string 17, symbol 2. Can't find a file" in this line:



WshShell.Run "datator.exe -f datatorrc -SocksPort " & Port & " -ControlPort " & CPort & " -DataDirectory datatorf" & i & countries, 0


What am I doing wrong? I don't know where the error is.










share|improve this question
















I have a vbs that runs several tor connections:



proxycount = 3
countries = ""

Set FSO = CreateObject("Scripting.FileSystemObject")
Set f = FSO.OpenTextFile("proxyList.txt", 2, True)

For i=0 To proxycount-1 Step 1

Port = 9000 + i
CPort = 8000 + i

If Not (countries = "") Then
countries = " -ExitNodes " & countries
End If

Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "datator.exe -f datatorrc -SocksPort " & Port & " -ControlPort " & CPort & " -DataDirectory datatorf" & i & countries, 0
WshShell = Null
f.WriteLine "127.0.0.1:" & Port

Next

f.Close


And it works great, but when I'm trying to pass on proxycount as a parameter:
CMD
it stops working:



countries = ""

Set FSO = CreateObject("Scripting.FileSystemObject")
Set f = FSO.OpenTextFile("proxyList.txt", 2, True)

For i=0 To WScript.Arguments(0)-1 Step 1

Port = 9000 + i
CPort = 8000 + i

If Not (countries = "") Then
countries = " -ExitNodes " & countries
End If

Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "datator.exe -f datatorrc -SocksPort " & Port & " -ControlPort " & CPort & " -DataDirectory datatorf" & i & countries, 0
WshShell = Null
f.WriteLine "127.0.0.1:" & Port

Next

f.Close


with error "string 17, symbol 2. Can't find a file" in this line:



WshShell.Run "datator.exe -f datatorrc -SocksPort " & Port & " -ControlPort " & CPort & " -DataDirectory datatorf" & i & countries, 0


What am I doing wrong? I don't know where the error is.







cmd vbscript






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 '18 at 21:53







Jooms

















asked Nov 13 '18 at 20:45









JoomsJooms

417




417












  • How do you pass the parameter? If it is a numerical value I believe this should work. It would not work if you pass it as say -10 (with the dash). Also, the line WshShell = Null does not what you want I think, should probably be Set WshShell = Nothing

    – Arno van Boven
    Nov 13 '18 at 21:36











  • @Arno van Boven, it is a numerical value "launch.vbs 2". I added the screenshot in the post.

    – Jooms
    Nov 13 '18 at 21:46











  • It would help if you also included the error you are getting

    – Arno van Boven
    Nov 13 '18 at 21:47











  • @Arno van Boven, string 17, symbol 2. Can't find a file.

    – Jooms
    Nov 13 '18 at 21:52











  • I don't immediately spot a difference. You'd expect a file with a 0 and a 1 if you pass 2 as the argument. (and 0, 1 and 2 in the hardcoded example). Check if you can find a difference in the generated filenames when using the different methods.

    – Arno van Boven
    Nov 13 '18 at 22:13

















  • How do you pass the parameter? If it is a numerical value I believe this should work. It would not work if you pass it as say -10 (with the dash). Also, the line WshShell = Null does not what you want I think, should probably be Set WshShell = Nothing

    – Arno van Boven
    Nov 13 '18 at 21:36











  • @Arno van Boven, it is a numerical value "launch.vbs 2". I added the screenshot in the post.

    – Jooms
    Nov 13 '18 at 21:46











  • It would help if you also included the error you are getting

    – Arno van Boven
    Nov 13 '18 at 21:47











  • @Arno van Boven, string 17, symbol 2. Can't find a file.

    – Jooms
    Nov 13 '18 at 21:52











  • I don't immediately spot a difference. You'd expect a file with a 0 and a 1 if you pass 2 as the argument. (and 0, 1 and 2 in the hardcoded example). Check if you can find a difference in the generated filenames when using the different methods.

    – Arno van Boven
    Nov 13 '18 at 22:13
















How do you pass the parameter? If it is a numerical value I believe this should work. It would not work if you pass it as say -10 (with the dash). Also, the line WshShell = Null does not what you want I think, should probably be Set WshShell = Nothing

– Arno van Boven
Nov 13 '18 at 21:36





How do you pass the parameter? If it is a numerical value I believe this should work. It would not work if you pass it as say -10 (with the dash). Also, the line WshShell = Null does not what you want I think, should probably be Set WshShell = Nothing

– Arno van Boven
Nov 13 '18 at 21:36













@Arno van Boven, it is a numerical value "launch.vbs 2". I added the screenshot in the post.

– Jooms
Nov 13 '18 at 21:46





@Arno van Boven, it is a numerical value "launch.vbs 2". I added the screenshot in the post.

– Jooms
Nov 13 '18 at 21:46













It would help if you also included the error you are getting

– Arno van Boven
Nov 13 '18 at 21:47





It would help if you also included the error you are getting

– Arno van Boven
Nov 13 '18 at 21:47













@Arno van Boven, string 17, symbol 2. Can't find a file.

– Jooms
Nov 13 '18 at 21:52





@Arno van Boven, string 17, symbol 2. Can't find a file.

– Jooms
Nov 13 '18 at 21:52













I don't immediately spot a difference. You'd expect a file with a 0 and a 1 if you pass 2 as the argument. (and 0, 1 and 2 in the hardcoded example). Check if you can find a difference in the generated filenames when using the different methods.

– Arno van Boven
Nov 13 '18 at 22:13





I don't immediately spot a difference. You'd expect a file with a 0 and a 1 if you pass 2 as the argument. (and 0, 1 and 2 in the hardcoded example). Check if you can find a difference in the generated filenames when using the different methods.

– Arno van Boven
Nov 13 '18 at 22:13












1 Answer
1






active

oldest

votes


















1














Adding this line in the beginning fixed the problem:



WshShell.CurrentDirectory = FSO.GetParentFolderName(WSH.ScriptFullName)





share|improve this answer






















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53289242%2fhow-to-pass-a-parameter-to-vbscript%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    Adding this line in the beginning fixed the problem:



    WshShell.CurrentDirectory = FSO.GetParentFolderName(WSH.ScriptFullName)





    share|improve this answer



























      1














      Adding this line in the beginning fixed the problem:



      WshShell.CurrentDirectory = FSO.GetParentFolderName(WSH.ScriptFullName)





      share|improve this answer

























        1












        1








        1







        Adding this line in the beginning fixed the problem:



        WshShell.CurrentDirectory = FSO.GetParentFolderName(WSH.ScriptFullName)





        share|improve this answer













        Adding this line in the beginning fixed the problem:



        WshShell.CurrentDirectory = FSO.GetParentFolderName(WSH.ScriptFullName)






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 15 '18 at 16:52









        JoomsJooms

        417




        417





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53289242%2fhow-to-pass-a-parameter-to-vbscript%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Darth Vader #20

            How to how show current date and time by default on contact form 7 in WordPress without taking input from user in datetimepicker

            Ondo