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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FSO and write to files

Status
Not open for further replies.
Sep 5, 2004
55
0
0
CH
Hi together

I use the code below to write datas to 2 Files (.htaccess and .htpasswd (which wil be used by IISPassword to protect Folders)
------------------------------------------------------------
<%Set fso = Server.CreateObject("Scripting.FileSystemObject")
Dim oShell
Set oShell = CreateObject("WScript.Shell")
strName= Request.Form("Benutzername")
strPasswort= Request.Form("Passwort")
const conVirtualPath = ".htaccess"
const conVirtualPath1 = ".htpasswd"
strPhysPath = Server.MapPath(conVirtualPath)
strPhysPath1 = Server.MapPath(conVirtualPath1)
set file= fso.opentextfile(strPhysPath,2, TRUE)
file.Writeline ("AuthName ""Bitte einloggen""") & vbcrlf
file.Writeline ("""AuthUserFile """) & strPhysPath & vbcrlf
file.WriteLine ("require valid_user")
oShell.run "cmd /c c:\tools\userline.exe" & strName & strPasswort & strPhysPath1
------------------------------------------------------------

now my problem is, that only .htpasswd will be created, but with the wrong content

Content of .htpasswd:

AuthName "Bitte einloggen"

AuthUserFilee:\inetpub\
require valid_user

and between AuthUserFile and the letter e shoud a space otherwise the file won't work

whats wrong?

Thank you for your help

best regards

E.Altherr
 
Try only using one set of speech marks e.g.
Code:
file.Writeline ("AuthUserFile ") & strPhysPath & vbcrlf

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
thanks
it works (with correct spaces)

but the following line will not be executed

oShell.run "cmd /c c:\tools\userline.exe" & strName & strPasswort & strPhysPath1

why?




 
Rather than using a run command on a shell object I would use the .NET Framework to start the other executable. e.g.
Code:
Dim MyProcess As New System.Diagnostics.Process
MyProcess.StartInfo.CreateNoWindow = True
MyProcess.StartInfo.UseShellExecute = True
MyProcess.StartInfo.WorkingDirectory = "c:\tools\"
MyProcess.StartInfo.FileName = "userline.exe"
MyProcess.StartInfo.Arguments = strName & strPasswort  & strPhysPath1
MyProcess.Start()


----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
the following error appears

Microsoft VBScript compilation error '800a0401'

Expected end of statement

/privat/protectadmin.asp, line 23

Dim MyProcess As New System.Diagnostics.Process

 
It isn't VBScript - it's .NET code. Where are you tring to run this from?

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
In that case you're in the wrong forum as this is for ASP.NET. Try forum333 for better results.

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top