locked
Script not working as expected RRS feed

  • Question

  • Hello All,
    
    I am beginner for the scripting, i wrote one small script which will trigger the CMD line on each remote machine given in the input file.
    
    The issue here is when I run the script the CMD line given in the script triggering only the local machine(where i am running) and its not going on the next machine given in the input file.
    
    
    
     
    Option Explicit
    
    dim inputfile,outputfile,objfile,objtextfile,strcomputer,objshell,strcmdline,objwritefile,output,pingoutput,,Nomadpath,Nomadfile,fileobjfile
    
    inputfile = "c:\temp\inputfile.txt"
    outputfile = "c:\temp\outputfile.txt"
    'Nomadpath = "C:\Program Files\1E\NomadBranch"
    'Nomadfile = "NomadBranch.exe"
    
    set objfile = createobject("scripting.filesystemobject")
    set fileobjfile = createobject("scripting.filesystemobject")
    set objshell = wscript.createobject("wscript.shell")
    
    set objtextfile = objfile.opentextfile("c:\temp\inputfile.txt",1)
    set objwritefile =  objfile.createtextfile ("c:\temp\outputfile.txt",8)
    
    Do until objtextfile.AtEndOfStream
    
    strcomputer = objtextfile.Readline
    
    set strcmdline =objshell.exec ("C:\Program Files\1E\NomadBranch\NomadBranch.exe -precache")
    
    pingoutput = strcmdline.stdout.readall
    
    output = wscript.echo (strcomputer &" " &pingoutput)
    
    wscript.sleep 1000
    objwritefile.writeline(strcomputer  &" "&pingoutput)
    wscript.sleep 1000
    
    loop
    
    
    
    Please help to fix the error in the script.
    
    
    
    Thanks 
    
    Suresh M


    THANKS SURESH M

    • Moved by Bill_Stewart Tuesday, December 18, 2018 12:28 AM This is not "fix/debug/rewrite my script for me" forum
    Thursday, October 11, 2018 5:32 AM

All replies

  • "Shell" cannot execute remotely.

    Consider using PowerShell.

    $sb = { & 'C:\Program Files\1E\NomadBranch\NomadBranch.exe -precache' }
    Get-Content c:\temp\inputfile.txt |
        ForEach-Object{
            Invoke-Command -ScriptBlock $sb -Computer $_    
        }


    \_(ツ)_/

    Thursday, October 11, 2018 8:41 AM
  • Please fix you post.  It is unreadable.


    \_(ツ)_/

    Thursday, October 11, 2018 8:50 AM
  • "Shell" cannot execute remotely.

    Consider using PowerShell.

    $sb = { & 'C:\Program Files\1E\NomadBranch\NomadBranch.exe -precache' }
    Get-Content c:\temp\inputfile.txt |
        ForEach-Object{
            Invoke-Command -ScriptBlock $sb -Computer $_    
        }


    \_(ツ)_/

    Thanks for your response <g class="gr_ gr_5 gr-alert gr_gramm gr_inline_cards gr_run_anim Punctuation multiReplace" data-gr-id="5" id="5">Jrv..</g>But we didn't enable WinRM to run the PowerShell to remote machines.

    Error:

    Connecting to remote server INCHXL206F8ED2D failed with the following error <g class="gr_ gr_9 gr-alert gr_gramm gr_inline_cards gr_run_anim Style multiReplace" data-gr-id="9" id="9">message :</g> The WinRM client cannot process the request


    THANKS SURESH M

    Thursday, October 11, 2018 8:53 AM
  • Please disable "Grammarly" before posting as it causes your post to be unreadable.  Contact Grammarly for a fix to you add-in.


    \_(ツ)_/

    Thursday, October 11, 2018 9:02 AM
  • Sorry...

    Thanks for your response ,but we didn't enable WinRM to run the PowerShell to remote machines.

    Error:

    Connecting to remote server INCHXL206F8ED2D failed with the following error The WinRM client cannot process the request

    Is there there any other way to run the script.


    THANKS SURESH M

    Friday, October 12, 2018 5:21 AM