Tuesday, March 1, 2011

Excel needs the Desktop

To make Excel automation works from IIS:
Excel uses the "Desktop" folder for something.
Even though IIS execution right personalized to an user specified in the application pool advanced settings, Excel still executes in the system environment, so, we need to create the desktop folder for it:

C:\Windows\System32\config\systemprofile\Desktop
read more at:

http://social.msdn.microsoft.com/Forums/en-US/innovateonoffice/thread/b81a3c4e-62db-488b-af06-44421818ef91?prof=required

Also, give proper rights to the folder "C:\Windows\System32\config\systemprofile\" and to the Excel's DCOM properties (go "Administrative Tools/Component Services") to the user which executes Excel

To run the DCOM config:
When the office has the same bits as the OS:
DCOMCNFG.exe

When 32bit office on 64bit OS:
mmc comexp.msc /32


Note! Even if the caller 32bit and the Excel is 64 bit, it should work fine, since the Excel object is called via DCOM.

Also! The Excel need a valid accessible printer to produce documents.
Make sure the default printer has enough permissions which allow the IIS user to print on it.

Saturday, January 22, 2011

about code optimization

You can not reduce the entropy. I redesigned a big chunk of code, shrank the file size by 200 lines (from 1400 to 1200), and the resulted .class file remained the same size.

Tuesday, January 18, 2011

If you need to send a BLOB to a HTTP server using vbscript, then you need
pass to the send() method the stream. But if it's multipart/form-data format, aside of the binary data the POST body should contain also boundaries and other metadata.
So, we have to store in a stream text data then binary then again some text.
It can be done by using the ADODB.Stream object.
It`s type (binary or text) can be converted dynamically, during the writing.
But! Before the setting the new type, the position has to be set to 0.
It can be then restored, after the type conversion to value taken from the stream.Size property.


option explicit

dim stream, file_loader, file_name, bnd
set stream = CreateObject("ADODB.Stream")
set file_loader = CreateObject("ADODB.Stream")
const adTypeBinary = 1
const adTypeText = 2
stream.Open
stream.Type = adTypeText
stream.CharSet = "iso-8859-1"

bnd
= "boundary"
file_name = "test.png"
stream.WriteText( "--" & bnd & vbCrLf & _
"Content-Disposition: form-data; name=""the_file""; filename=""" & file_name & """" & vbCrLf & _
"Content-Type: application/octet-stream" & vbCrLf & vbCrLf )

stream.Position = 0
stream.Type = adTypeBinary
stream.Position = stream.Size

WScript.Echo "Position before file loading: " & stream.Position

file_loader.Open
file_loader.Type = adTypeBinary
file_loader.LoadFromFile(
file_name )

file_loader.CopyTo stream

stream.Position = 0
stream.Type = adTypeText
stream.CharSet = "iso-8859-1"
stream.Position = stream.Size
WScript.Echo "Position after file loading: " & stream.Position
stream.WriteText( vbCrLf & "--" & bnd & "--" & vbCrLf )
stream.Position = 0
stream.Type = adTypeBinary

dim http_req
set http_req = CreateObject("WinHTTP.WinHTTPRequest.5.1")
'WinHTTP.WinHTTPRequest.5.1 better than Msxml2.XMLHTTP because it lets you override the http headers
call http_req.SetProxy( 2, "127.0.0.1:8888" ) ' for Fiddler proxy
call http_req.open( "POST", "http://127.0.0.1/", false )
call http_req.send( stream )

Tuesday, December 28, 2010

G

The first impression of the new Android cookery called "Gingerbread" - definitely do not like it.
It slow as hell, ugly black, nice round corners of buttons now straight and sharp.
Why everything becomes worse???

Wednesday, December 22, 2010

IIS Authentication

By default, there are only three kind of authentication: Anonymous, ASP.NET and Forms in IIS7. Old good (?) Basic/Digest/Windows Authentication are not available.
To make them enabled, go to the roles in "Server Manager", in the context menu choose "Add Role Services". Enable the desired Authentication features.

Monday, December 13, 2010

IIS7 in maximum application security mode

When IIS7's application pool is set to use the "ApplicationPoolIdentities", the system dynamically creates an user with the name as "IIS AppPool\< application pool name >".
This user is not listed in the right assignment dialog's "Find" feature, but can be entered manually to setup the permissions (Or use the icacls command, like ICACLS folder_name /grant "IIS AppPool\DefaultAppPool":F ). Also, this user in the "IIS_IUSRS" group, so, by assigning the necessary permissions to the group it gives the same rights to that user as well.
To send SMTP Email using CDOSYS object, need not only to give the writing rights to the "Mailroot\Pickup" folder, but also то give the read right to the metabase's "IIS://LOCALHOST/SMTPSVC" and "IIS://LOCALHOST/SMTPSVC/1" to let the CDO know where the pickup folder is.

Sunday, December 5, 2010

the. curse

I wish the one who invented to use the capacitive toouch screens in mobile devices burn in the hell forever.
Published with Blogger-droid v1.6.5