473,407 Members | 2,306 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

How do I append a file in Remote machine using VB SCRIPT?

Hi ALL,

This realates to vb script code to append a file in C Drive in a remote machine accessed from a machine in different domain. I am able to successfully connect to the machine, but the file entry is not successful. I am Placing the snippet here.. Plz let me know.

On Error Resume Next
COnst ForAppending = 8
Set filesys = CreateObject("Scripting.FileSystemObject")
Set readfile = filesys.OpenTextFile("machine.txt", 1, false) ' For Reading
Do Until readfile.AtEndOfStream
MachineName = readfile.ReadLine
msgbox MachineName
Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
strdomain = "test"
Set objSWbemServices = objSWbemLocator.ConnectServer(MachineName, "root\cimv2", "vvv", "ssss","MS_409","ntlmdomain:" +strdomain)
msgbox Err.number
If Err.number = 0 Then 'If remote connectivity is successful

Set objFSO = CreateObject("Scripting.FileSystemObject")
filePath = "\\" & MachineName & "\\C$\WINDOWS\system32\drivers\etc\hosts"
Set objFile = objFSO.OpenTextFile(filePath, ForAppending, True)
objFile.WriteLine "192.81.255.255"
objFile.Close

Else 'If error connecting to Remote Host/Registry
WScript.Echo "Error connecting to the Remote Host/Registry on : " & MachineName

End If
Loop

readfile.Close

MsgBox "Script has been successfully executed.."


It says logon failure at line 16.
Error code was zero, hence the connection is successful.
But I donno why is it not taking the file path C$..when the user credentials look fine too.

Kindly advice me through this.
Jan 10 '11 #1
1 1820
Can some1 plz help me through this?
Jan 11 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Winterminute | last post by:
I am trying to read a list of install programs using WMI with ASP.NET/C#. However, it fails with "Invalid Class". I have confirmed that if I query LOCALHOST then it works fine, but if I query a...
1
by: Maximus | last post by:
hi all, I want to kow if there is a way to connet a machine using a VPN client through vb.net or c# code. I have requirement where i need to copy file using VPN. Hence, I need to start the...
1
by: remya1000 | last post by:
from my system i need to open a calculator in remote machine. and i'm using Vb.net and WMI. i need to pop up the calculator in remote machine, while i run one program in my system. while running in...
0
vinoj
by: vinoj | last post by:
Hi All, These are the following things which i want to do:- 1. I will be taking the ipaddress, username and password from the user using cgi ffrom the browser. 2. Now i want...
1
by: thamayanthi | last post by:
Hi, Please find the below code which is used to Print the Operating System of a remote Machine of linux.This code is working fine,if i give the correct UserName and Password of a machine but what...
2
by: pnalla | last post by:
hi, I can aceess ths windows services on remote machine. but i can not start and stop the services.it gives some error message like " can not open 'service name' on comuter 'machine name'. Please...
2
by: pnalla | last post by:
How to access windows services on remote machine using C#.please give me some example code.also how to start/stop service on remote machine .please give me some example code. thanks prasad
0
by: qwerty27 | last post by:
how to get version of installed component services on remote machine using c#? this is for local machine....but i want fr remote machine COMSVCSLib.MtsGrpClass group = new...
2
by: vimalsantoki | last post by:
Any one please help me in c#. I want to start a GUI process in remote machine using c#.net. I have develop one windows application for LAN in which I provide a facility of remote process start...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.