VBscript and impersonation
- From: "Jim Andersen" <nospam@xxxxxxxxx>
- Date: Thu, 30 Nov 2006 11:22:40 +0100
I've tried to run a VBscript with elevated privileges, but with no success.
My code works fine, except if I try to run it using impersonation.
Have anyone made it work ? Will you try it on your installation to see if it
works? Shouldn't take more than a few minutes.
I have used the "Impersonation" setting in web.config.
I have tried Process.Start and specified username/password in
When supplying username/password to Process.Start it calls an unmanaged API,
LogonUser, so I also tried calling that directly.
But vbscript simply won't start.
It gives me this error:
Microsoft Windows scripting version 5.6 (etc... the banner-info) followed by
"Windows Script Host"...
"Can't find script engine 'VBScript' for 'C:\test.vbs'."
or "application failed to initialize properly (0x0000142)"
Googling for these suggested installing the latest version of vbscript, or
re-installing, or messing with registry-keys but nothing helped.
This is the code for a webform with a label and a button:
Protected Sub knpCommit_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles knpCommit.Click
Dim myProcess As New Process
Dim output As String
.FileName = "c:\windows\system32\cscript.exe"
.Arguments = "c:\TestScript.vbs"
.UseShellExecute = False
.RedirectStandardOutput = True
Me.Label1.Text = "efter start"
output = myProcess.StandardOutput.ReadToEnd()
Me.Label1.Text = output
With this in web.comfig it fails:
<identity impersonate="true" userName="myDomain\myUserName"
This is the script in c:\TestScript.vbs:
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\ScriptLog.txt", 2)
Set WshNetwork = WScript.CreateObject("WScript.Network")
WScript.Echo "Testscript 1: Username: " & WshNetwork.UserName
- Prev by Date: Re: ASP.NET 2.0's Membership, Roles, and Profile for different client
- Next by Date: Re: ASP.NET 2.0's Membership, Roles, and Profile for different client
- Previous by thread: ASP.NET 2.0's Membership, Roles, and Profile for different client
- Next by thread: Re: VBscript and impersonation