<%
virtPath = "\\mnbv00ww7044832\central engineer\OH\OSP Engineering\ATHN\2011"
''#virtPath = "C:\central engineer\OH\OSP Engineering\ATHN\2011"
dim fs
set fs=Server.CreateObject("Scripting.FileSystemObject")
if fs.FolderExists(virtPath) then
response.write(virtPath & " exits !!!")
else
response.write(virtPath & "does not exist")
end if
set fs=nothing
%>
According to this code the folder exists when i give path as C:... , but it shows that the folder does not exist when i try to access it through the computer name. I tried almost everything that i could come up with, but for some reason i cannot find the solution. basically i need to access a folder on a different computer.
Thanks
Nik
First its not clear that you understand that you cannot simply substitute the "\mnbv00ww7044832" for "c:". However lets assume you have actually created a network file share with the name "central engineer" on the "central engineer" folder.
You need to ensure that the user security token being used to access the share has not only access to the folder but also has access to the share.
Related
In case, i'm create function to process excel and in the end of process i want to save excel into my "Download" folder in my pc.. but i get a different folder path between my pc and my server.. when i running my application using my pc, i get path "C:/Users/MyPCUserName/Downloads" but when i running application on published file (iis server), i get path "C:\Users\SYSTEM\Downloads\85FE1000".. I don't know what's the wrong with my code / function..
This my Code :
Private Sub myMethod(ByVal pProjectNo As String, ByVal pOrderNo As String)
Dim dt As DataTable = ClsUploadBreakDownInquiryDB.GetFinalInspectionData(pProjectNo, pOrderNo)
if dt.Rows.Count > 0
'My Function Here
Dim user As String = System.Environment.UserName
exl_b2.SaveAs("C:\Users\" & user & "\Downloads\" & pProjectNo & "_" & Microsoft.VisualBasic.Format (Date.Now, "yyyyMMdd_HHmmss") & ".xlsx", Excel.XlFileFormat.xlOpenXMLWorkbook)
End If
End Sub
You can save a up-loaded file on your web server quite much any place you want.
However, if you talking about a client side user - and their browswer download lcoation? You have ZERO, but 100% ZERO control over that location.
In fact, the user might be using a iPhone, or Android - and not even a desktop comptuer.
You do not have ANY ability in ANY case to control the location of a user download of a file. Files on the local computer are 100% hands off. When they download, it will usually go to their downloads folder - but the user settings control that.
You can't grab, see, or set ANY file location on the client side computer. I mean, if you could do that, then when you come to my site to view a cat picture? My code would then rummage around on your computer - looking for files called passwords, or files called banking etc and steal them
So, server side code behind? Sure, you can in most cases save the file on the web server computer anywhere you like - it don't matter a whole lot.
However, if you talking about client side computer locations for the user and their browser hitting your web site? No, you have zero information, zero control over the users files, and even where they choose to save, or download such files - that is their computer - and browsers give protection for reasons of security.
This can sometimes be confusing when using Visual Studio during development, since your computer, your browser and your web site are all running on the ONE SAME computer, but in a typical deployment, that of course is not the case. So, code behind has zero knowledge about the users local file system.
As a result, you cannot grab, or set ANY kind of file location information on the client side computer.
So, saving to "users" with code behind is ONLY going to apply to the code behind web server "user", and has nothing to do with the client side user.
As a general rule, any and all folders you work with and use from code behind? In EVERY case that should be a sub folder of your root of your project.
Keep in mind:
Any markup code - urls - that is relative to your web site
Any code behind - plane jane windows path name.
So, if you add a folder to your project, it might be say folder UpLoadFiles.
So, then web based, mark up based will be like this:
https://localhost:44392/UpLoadFiles/doc.pdf
So, UpLoadFiles is simple a sub folder in your project.
However, in code behind, your code ALWAYS works with plane jane valid windows file names. So, to convert above to a plane jane file path in windows? You do this:
Dim strFile As String = Server.MapPath("~/UpLoadFiles/abc.txt")
Dim strText As String = File.ReadAllText(strFile)
At this point, now str file is a plane jane valid full good old fashioned windows file name.
So, code behind = always plane jane window path name
So, web markup and URL = always a relative path from your project root.
dim strTextFile = File.ReadAllText(strFile).
I am setting up a new test server for an application created by a previous developer. Please see the code below:
strLines = Split(strData, vbCrLf)
lngLinesRead = UBound(strLines)
intFile = FreeFile
Open "log.txt"For Append As #intFile
Print #intFile, Now & " ***************** Start of import. User: " & strUser & " on: " & strTerminal & " ******************** "
Close #intFile
This code is creating a log file in the following location: "c:\windows\syswow64\isvr\log.txt. On the live server (and existing test server) it is written to: c:\iispages\app\log.txt. How do you specify the relative path? Is this done in IIS.
When creating a scheduled task; there is a 'start in' option where you can specify the starting directory. Is there something similar in IIS?
The file is going to be written into the "current folder" of the web server. This will be the folder where the ASP page is executed from. The two paths you posted represent the active folders the different web servers were using when those files were written. You can specify a deeper path in the Open statement:
Open "c:\windows\syswow64\isvr\SUBFOLDER\SUBFOLDER\log.txtFor Append As #intFile
But since this is being managed by IIS, it must be a folder that IIS service is allowed to write to. If you need to write to a folder outside the scope of the web service you can edit the folder permissions in windows to give permission.
before I start, I'm a PHP programmer, not an ASP programmer, but at my job, they use ASP and I don't have acces to the server, but I can contact the person in charge.
I'm working on an ASP function for work and I alway hit this "Permission denied" error. I made some search and I found that the account need permission to run the script. It's maybe just me, but I don't understand that ASP check the user before run a script, I mean, it's a public website, obviously they will not have acces if I don't.
Can I change the file so anyone can run it ?
EDIT :
My script is trying to edit a file on the server
dim fs,f
set fs=Server.CreateObject("Scripting.FileSystemObject")
set f=fs.OpenTextFile(Server.MapPath("test.txt"),8,true)
f.WriteLine("This text will be added to the end of file")
f.Close
set f=Nothing
set fs=Nothing
Thanks
The account that IIS uses (probably iusr) needs to have read/write permissions on the target folder. I would recommend using a temp folder (anything other than the website's root folder)
By default, the account will have no permissions. That's simply basic security. You need to have whoever administers that machine give permissions on an appropriate location.
I have a classic asp application which retrieves the current application name and sets an Application variable containing that name. This name is important (I wont go into why) and is essentially the friendly name in IIS.
The problem is, the implementation used to get this name is flawed, it a) assumes the home directory contains the string wwwroot, and b) assumes the folder name is the same as the application name. I can no longer guarantee these conditions.
I would have thought the application name is know at run-time but I can't seem to find it in either Session or Application variables (at application start up entry point in global.asa). Any ideas?
You may want to try something like this:
Dim obj
Dim inst
inst = Request.ServerVariables("INSTANCE_ID")
Set obj = GetObject("IIS://localhost/W3SVC/" + inst)
Response.Write obj.ServerComment
If by friendly name you are referring to the IIS description, you might get some mileage out of the findweb.vbs file in the AdminScripts Folder of IIS (normally c:\Inetpub\AdminScripts) Some of the other scripts in that folder might be able to get you further too.
Try this aswell. It shows how to enumerate the IIS Websites through ADIS
This is kind of an advanced problem, hopefully one of you asp/VB gurus will have a suggestion. I am trying to dynamically set a folder's execute permissions in IIS6 from an asp page. I have given the server full permissions to make the changes necessary. When I run the code I get:
Microsoft VBScript runtime error '800a0046'
Permission denied: 'GetObject'
/learning.asp, line 11
I have a server setup with IIS6 running a couple asp websites. I use a code like this to create a folder called "files"
set fso = Server.CreateObject("Scripting.FileSystemObject")
set folder3 = fso.CreateFolder(Server.MapPath(username & "/files"))
set folder3 = nothing
set fso = nothing
Works fine and creates the files folder just where I want it. However, the new folder has execute permissions set to "scripts and exe's" and I need it to be "never" or false. There is a system object that you can call to make this change, and I even have a piece of code that I wrote after reading another tutorial.
It doesn't work and gives the above error. I think, maybe, I am just leaving something out, but this stuff is a little over my head. Here is what I used, but I don't know the syntax or what exactly to call.
Set root = GetObject("IIS://localhost/" & username)
Set newVDir = root.Create("IIsWebVirtualDir","files")
newVDir.Path = "e:\iis3\server2\ADSI"
newVDir.AccessScript = False
newVDir.SetInfo
I have searched around for 3 days trying to find a solution to this, but not very many people do this type of thing apparently, because there are no posts about it that I can find.
Anyway, I don't understand what the getobject is supposed to do, and what newVDir.path I am supposed to be using?
Thank you, in advance, for any helpful suggestions you may have.
This article (see http://technet.microsoft.com/en-us/library/bb742439.aspx) explains what the GetObject actually does.
I believe, what happens behind the scene is that a COM object of type "IIS Admin Service" is (needs to be) created to perform your operations. By default, the IIS application pool account is not allowed to create such object. So maybe its worth to check it. Open Control panel->Administrative services, run "Component services". Find "my computer" in the tree and there find "IIS admin service". Check "activation" and "launch" permissions, add some if necessary.