Sharepoint not letting iis to trigger cmd.exe using processstartinfo
-
03-10-2020 - |
Question
Server: Windows Server 2008 R2 Standard.
Sharepoint page : SharePoint 3.0
Set the application pool identity to use the Local System
Logged in as administrator
the code works fine on the above system but when tried on the same but enterprise server(Server: Windows Server 2008 R2 Enterprise) - cmd.exe is not triggered
Dim cmds As Diagnostics.ProcessStartInfo
Dim cmdr As Diagnostics.Process
cmds = New Diagnostics.ProcessStartInfo
cmds .FileName = "cmd.exe"
cmds .Verb = "runas"
cmds .WorkingDirectory = "C:\Program Files\Menton\Setup"
cmds .UseShellExecute = True
cmds .RedirectStandardOutput = False
cmds .RedirectStandardInput = False
cmds .RedirectStandardError = False
cmds .CreateNoWindow = True
cmdr = Process.Start(cmds)
cmdr.WaitForExit()
Works on Windows Server 2008 R2 Standard
It doesn't work on Windows Server 2008 R2 Enterprise with all same settings and configurations
Solution
Microsoft Windows SharePoint Services uses impersonation so that code running within a executes with the identity and permissions of the current user.
However, occasionally your code must call restricted methods within the Windows SharePoint Services object model even though the request is initiated by a nonprivileged user. In such cases you must be able to elevate the privilege of your code as it executes on the Web server.
SPSecurity.RunWithElevatedPrivileges(AddressOf MyElevatedMethod)
Sub MyElevatedMethod()
'Your code goes here
End Sub