Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Not able to create a text file using FSO

Posted on 2006-04-26
11
Medium Priority
?
273 Views
Last Modified: 2010-04-17
Hi,

I have written a program as part of our intranet aplication that helps users to print reports from our web site. Basically, the page shows a list of files under a folder and a small printer icon infront of it. If the user wants to print that file, he clicks on the printer icon which brings up a small window with a dropdown list of the printers available to him. He selects a printer and clicks on "print" button. The form submits to another page of code with the "printer name" and "file name" and all the work is done in the second page.

I am getting error in this page. Basically, I am creating an object of Shell and sending the print job to command prompt programmatically. Before the requested file is sent to comand prompt, it is recreated in another folder, "temporary". Error is being pointed to this line of code where the temporary file is created.

set tempfile = fso.createtextfile(tempfolder & "\" & tempfilename & cstr(tempfilenum))

The actual code is in some other folder, let's say "A" and the temporary file is being created in completely different folder, let's say "B" which is out of "A".

Any help or suggestions to fix this please? This has to be fixed very urgently.

Thanks,
0
Comment
Question by:arsmed840
11 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 16546921
And the error message is?
also, what is the value of
tempfolder & "\" & tempfilename & cstr(tempfilenum)
0
 

Author Comment

by:arsmed840
ID: 16547254
The error message is

Microsoft VBScript runtime error '800a0046'

Permission denied

The value of tempfolder & "\" & tempfilename & cstr(tempfilenum) is as following.

tempfolder - is "temporary" as I told you earlier which is already existing, that means the program need not create.
tempfilename - is fixed, "print-temp."
tempfilenum - is a number that gets incremented in a loop every time a new file is requested to print. it starts with a value of "0".

I want to be more clear on the last thing, tempfilenum. Each time a file is requested to print, a temporary file is created. The name of the file is varied only with the number in the last. Rest of the filename is same for every file. Once the file is created it stays there till we delete them manually.
So, I browse through the files created taking the filenum as "0" initially, and incrementing it by one, and do loop is as follows.
    tempfilenum = "0"    
    do while fso.fileexists(tempfolder & "\" & tempfilename & cstr(tempfilenum))
        tempfilenum = tempfilenum+1
    loop
    set tempfile = fso.createtextfile(tempfolder & "\" & tempfilename & cstr(tempfilenum))

Please let me know if you need more information.

Thanks,
0
 
LVL 11

Expert Comment

by:WelkinMaze
ID: 16548181
Hi,
Are you sure that the error comes from this line? Could you check if the program really stops there or go through it and the error comes from some of the next rows? It happens sometimes for different reasons the line shown for an error to be incorrect.

Also you can look here for some info:
http://computerperformance.co.uk/Logon/code/code_800A0046.htm
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:arsmed840
ID: 16548341
Hi WelkinMaze,

I checked the code and the error was right at the line I told as above. I added "everyone" also in the user names of temporary folder. Luckily it started working. I mean, it is able to create the file in that file with proper increments.
And now the problem is showing up at a different place.

After creating the file I am sending that to print using WScript.shell's run method. Now the error is showing up at this line.
txtreturn=WShell.Run(runstring, 1, true)

I tried to print the runstring to the screen. It is grabbing the right value. I called parameter runstring's value directly at the command prompt of the server. It printed the file perfectly. But, when I call the program through IIS(as the code is in an .asp file), it is throwing up the same error I said above.

Microsoft VBScript runtime error '800a0046'

Permission denied

Thanks so much,

0
 
LVL 11

Expert Comment

by:WelkinMaze
ID: 16548420
are the permissions for the printer ok?
or is runstring has the full paths in it?
0
 

Author Comment

by:arsmed840
ID: 16548490
Hi WelkinMaze,

I am not sure of the permissions for the printer. Please tell me what and how to check. I will do it.

And runstring is really fine. Because, I tried to write it to page. It printed the string value correctly. And I typed the same string value it returned at the command prompt to print the file. It printed perfectly.

The only thing I am wondering is why it is stopping at the same line when I call it in the code. Is IIS not able to use "run" method of shell object or not able access? Or are there any permissions need to be checked on the shell object's dll also?

Thanks,

0
 
LVL 11

Expert Comment

by:WelkinMaze
ID: 16548612
you also need permissions on wscript.dll and any dll's your executable requires to run.

and this one is taken from the link below:
"I use IIS6 , the only thing I had to do was to assign another working process to my application.
That working process ha to start as a Local System not as Network Service."

http://www.experts-exchange.com/Web/Web_Languages/ASP/Q_21046917.html?qid=21046917
0
 
LVL 11

Expert Comment

by:WelkinMaze
ID: 16548620
And these are the solutions from the initial link I've posted (http://computerperformance.co.uk/Logon/code/code_800A0046.htm):
The Solutions
If its Exchange, then check the MailRoot and Pickup folder permissions.  If its IIS check the permissions to run scripts.  If its SQL check the execute permissions on the services.  

The solution in the printer problem below would be to change the share permissions on the HP6L printer share.
0
 
LVL 6

Expert Comment

by:tone28
ID: 16548829

Are you using ASP? You will need to use Server.MapPath

set tempfile = fso.createtextfile(Server.MapPath(tempfolder & "\" & tempfilename & cstr(tempfilenum)))
0
 

Author Comment

by:arsmed840
ID: 16548854
In this scenario, what permissions should I add or check on dlls. I mean other than wscript.dll, do I need to change permissions on any other dll. And also, what kind of permissions should I check, please tell me.

Here, I am just trying to print the file by instantiating the shell object and by passing the run command through an asp file. So, it should be IIS. Not Exchange or SQL. But, I already granted permission for that application to run scripts. So, that is fine.

>The solution in the printer problem below would be to change the share permissions on the HP6L printer share.
Where should I check for this? I am sorry. I am not a network person, so, I don't have too vast idea on all these permissions and dependencies.

Thank you so much,
0
 
LVL 4

Accepted Solution

by:
adam_pedley earned 1500 total points
ID: 16549724
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Loops Section Overview

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question