Asked by:
Script not working as expected

Question
-
Hello All,
I have created the script to run the below given cmd line, but when i run the script the cmd executed on local machine where i run the script not the other machines,
Please check the script and advise me to correct it.
Option Explicit dim inputfile,outputfile,objfile,fileobjfile,objshell,objtextfile,objwritefile,strcmdline,strcomputer inputfile = "c:\temp\inputfile.txt" outputfile = "c:\temp\outputfile.txt" 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") objwritefile.writeline (strcomputer) loop
THANKS SURESH M
- Moved by Bill_Stewart Thursday, December 20, 2018 10:02 PM This is not "debug/fix/rewrite my script for me" forum
Monday, October 29, 2018 11:56 AM
All replies
-
You could make your life easier when you use Powershell
Get-Content -Path 'c:\temp\inputfile.txt' | ForEach-Object -Process { Invoke-Command -ComputerName $_ -ScriptBlock {& 'C:\Program Files\1E\NomadBranch\NomadBranch.exe' -precache} } | Out-File -FilePath 'c:\temp\outputfile.txt'
Of course you have to have administrative rights on the target remote computers and you should have enabled Powershell remoting.Live long and prosper!
(79,108,97,102|%{[char]$_})-join''
Monday, October 29, 2018 12:32 PM -
Thanks for your response.....
But we have not enabled power shell remoting in our environment, so we unable to execute it.
it would be better if you can correct the VBS.
THANKS SURESH M
Monday, October 29, 2018 1:39 PM -
VbScript cannot remotely execute a file like that. Use WMI to execute an EXE remotely.
\_(ツ)_/
Monday, October 29, 2018 7:42 PM -
You can also use PowerShell directly (no remoting).
$commandLine = '"C:\Program Files\1E\NomadBranch\NomadBranch.exe" -precache' Get-Content -Path 'c:\temp\inputfile.txt' | ForEach-Object -Process { Invoke-CimMethod -ComputerName $_ -Class Win32_Process -MethodName Create -Arguments @{CommandLine = $commandLine} }
\_(ツ)_/
- Edited by jrv Monday, October 29, 2018 7:53 PM
Monday, October 29, 2018 7:51 PM