0

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

  • executed by web service – user42300 May 12 '15 at 19:55
  • yeah it is hosted on sp – user42300 May 12 '15 at 19:56
  • Try elevating code block.. SPSecurity.RunWithElevatedPrivileges... – Amal Hashim May 12 '15 at 19:56
  • thanks. I have come across that before too. But im a bit confused why would that work on one server with same privileges and not on another with same settings n configs.. ? – user42300 May 12 '15 at 19:58
  • I suspect permission issue. The user account which you used on the other server might have proper permissions. – Amal Hashim May 12 '15 at 19:58
0

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
  • Thanks. What is the library should I import to use SPSecurity in vb? – user42300 May 13 '15 at 17:06
  • Microsoft.SharePoint.dll – Amal Hashim May 13 '15 at 17:07
  • Sorry I need to run specific code block within a private function... how can i do that? – user42300 May 13 '15 at 17:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.