Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Read Text file on C$ share

Status
Not open for further replies.

acewilli

IS-IT--Management
Apr 11, 2003
98
US
Hello, how can I read a text file on an Admin share on a remote computer? I keep getting permission denied. I even tried to create a new share to the C drive and connect to it but it still is giving me permission denied.

Thank you,

acewilli
 
How are you accessing the drive: using C$ or the new share. It should work if you access it via the new share using the new share name that you have given (not C$).
 
More importantly, did you set the permissions of your new share? What account are you logged in on at your workstation? Does that account have admin rights to the remote machine?

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
 
Well the problem I believe is because I am doing this through ASP. I have no idea how to get it to quit denying me because of permissions. I thought about doing something like the code below but it is starting to get out of hand. I have a search.asp that takes in the server name and the search string and then it goes to the page below which is called searchresult.asp. I hope this helps to understand my problem. I've tried numerous ways to do this and the code below is the last way that I've been trying. I've tried mapping drives to my webserver from the servers that I am trying to retrieve the information from.

Code:
<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<P><H3>Search Results</H3></P>
You have searched for: <B><%=Request("TextToSearch")%> on <%=Request("Select")%></B>
<hr>

<%
Dim strtextToSearch
Dim strselect
Dim strfile
Dim strcmd

strtextToSearch = Request("TextToSearch")
strselect = Request("Select")
'Now, we want to search all of the files
Dim fso

Const ForReading = 1
Set fso = Server.CreateObject("Scripting.FileSystemObject")

'Specify the folder path to search.
Dim FolderToSearch
If strselect = "DTC0B00BD5A3B8B" then
	FolderToSearch = "K:\BP2000.log"
	strcmd = "%comspec% /Q /C find /I " & Chr(34) & strTexttoSearch & Chr(34) & " " & FolderToSearch & " >K:\output.txt"	
	strfile = "K:\output.txt"
elseif strselect = "DTC0D0065A9FEE1" then
	FolderToSearch = "L:\BP2000.log"
	strcmd = "%comspec% /Q /C find /I " & Chr(34) & strTexttoSearch & Chr(34) & " " & FolderToSearch & " >L:\output.txt"	
	strfile = "L:\output.txt"
elseif strselect = "DTC0D0065EFC8FE" then
	FolderToSearch = "M:\BP2000.log"
	strcmd = "%comspec% /Q /C find /I " & Chr(34) & strTexttoSearch & Chr(34) & " " & FolderToSearch & " >M:\output.txt"	
	strfile = "M:\output.txt"
else
response.write "File does not exist!"
end if

    Dim oWSH
     Set oWSH= Server.CreateObject("WScript.Shell")
     oWSH.Run strcmd, 0, True
     set oWSH = nothing

Call getinfo(strfile)

Function getinfo(strfile)
IF fso.FileExists(strfile) THEN
        response.write "file exists" & "<br>"
	Set objTextStream = fso.OpenTextFile(strfile,ForReading)
	    'Read the content
	    strFileContents = objTextStream.ReadAll
	       Response.Write "<B>" & strFileContents & "</B>"
	    objTextStream.Close
Else
		response.write "Please wait on file to be created."
		WScript.sleep 20
		Call getinfo(strfile)
End If
End Function
	'Destroy the objects
	Set objTextStream = Nothing
'	Set objFolder = Nothing

Set fso = Nothing
%>
<center><a href="search.asp">Back</a></center>
</BODY>
</HTML>
 
Configure the anonymous credentials in IIS to have NTFS rights to the machine in question and use NTFS rights on the web page itself to restrict users from accessing it.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
 
How do I do this? I'm not sure exactly where to make this change.
"Configure the anonymous credentials in IIS to have NTFS rights to the machine"

How do you give NTFS rights to the web page?
"use NTFS rights on the web page itself"

Sorry but this confused me even more. I can give NTFS permissions to the folder of the website and I can make the anonymous user account a member of the Administrator group on the web server but no way to do that on the servers in question since the anonymous account is a local account.

Thanks for helping me to understand this above. I appreciate it.

acewilli
 
WHen you enable anonymous access you will note below that there is an account listed, usually IUSR_MACHINENAME. You can change this to an account that has rights on the remote box.

On your web server, to restrict access to the web page, navigate to the page using Windows Explorer. Right click the ASP file and choose properties. Click the security tab and restrict read access to the accounts you want.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
 
Okay...looks like the permissions are okay now but I am getting this error.

Code:
Error Type:
Microsoft VBScript runtime (0x800A004C)
Path not found
/basepage/searchresult.asp, line 53

The paths are there. I just don't think I'm going about this right. If you have another way that I could read text from a text file on a remote machine and display it to an ASP page please let me know.

Thanks again,

acewilli

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top