我在项目里是通过cmd启动flashpaper转换文件的。项目在xp里部署可以正常转换,但是到server 2003死活不行,也不报异常iis管理员权限都给了。还不行。今天调了一天了,现在才回到家,还没吃饭快崩溃了。。倾家荡产求解关键代码:public static void TransformFile(string filepath)
    {
        string fppath = System.Configuration.ConfigurationManager.AppSettings["Flashpaper"];
        string outpath = filepath.Substring(0, filepath.LastIndexOf('.')) + ".swf";
        string param = fppath + " " + filepath + " -o " + outpath;
        Process p = new Process();
        p.StartInfo.FileName = "C:\\WINDOWS\\system32\\cmd.exe";
        p.StartInfo.UseShellExecute = false;
        p.StartInfo.RedirectStandardInput = true;
        p.StartInfo.RedirectStandardOutput = true;
        p.StartInfo.RedirectStandardError = true;
        p.StartInfo.CreateNoWindow = true;
        //p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
        try
        {
            p.Start();
            string strOutput = null;
            p.StandardInput.WriteLine(param);
            p.StandardInput.WriteLine("exit");
            strOutput = p.StandardOutput.ReadToEnd();
            Console.WriteLine(strOutput);
            p.WaitForExit();
            p.Close();
        }
        catch (Exception ex)
        {            
            throw ex;           
        }
    }

解决方案 »

  1.   

    在server2003中设置文件类型映射!!
      

  2.   

    1楼说的是mime类型吗?设置了。2楼,我手动在2003里用命令行调用flashpaper是可以正常运行转换的。
      

  3.   

    Impersonate一个管理员账号给CMD来做这个事情
    参考文档:
    http://support.microsoft.com/kb/306158参考代码:<%@ Page Language="C#"%>
    <%@ Import Namespace = "System.Web" %>
    <%@ Import Namespace = "System.Web.Security" %>
    <%@ Import Namespace = "System.Security.Principal" %>
    <%@ Import Namespace = "System.Runtime.InteropServices" %><script runat=server>
    public const int LOGON32_LOGON_INTERACTIVE = 2;
    public const int LOGON32_PROVIDER_DEFAULT = 0;WindowsImpersonationContext impersonationContext; [DllImport("advapi32.dll")]
    public static extern int LogonUserA(String lpszUserName, 
    String lpszDomain,
    String lpszPassword,
    int dwLogonType, 
    int dwLogonProvider,
    ref IntPtr phToken);
    [DllImport("advapi32.dll", CharSet=CharSet.Auto, SetLastError=true)]
    public static extern int DuplicateToken(IntPtr hToken, 
    int impersonationLevel,  
    ref IntPtr hNewToken);
                              
    [DllImport("advapi32.dll", CharSet=CharSet.Auto, SetLastError=true)]
    public static extern bool RevertToSelf();[DllImport("kernel32.dll", CharSet=CharSet.Auto)]
    public static extern  bool CloseHandle(IntPtr handle);public void Page_Load(Object s, EventArgs e)
    {
    if(impersonateValidUser("username", "domain", "password"))
    {
    //Insert your code that runs under the security context of a specific user here.
    undoImpersonation();
    }
    else
    {
    //Your impersonation failed. Therefore, include a fail-safe mechanism here.
    }
    }private bool impersonateValidUser(String userName, String domain, String password)
    {
    WindowsIdentity tempWindowsIdentity;
    IntPtr token = IntPtr.Zero;
    IntPtr tokenDuplicate = IntPtr.Zero; if(RevertToSelf())
    {
    if(LogonUserA(userName, domain, password, LOGON32_LOGON_INTERACTIVE, 
    LOGON32_PROVIDER_DEFAULT, ref token) != 0)
    {
    if(DuplicateToken(token, 2, ref tokenDuplicate) != 0) 
    {
    tempWindowsIdentity = new WindowsIdentity(tokenDuplicate);
    impersonationContext = tempWindowsIdentity.Impersonate();
    if (impersonationContext != null)
    {
    CloseHandle(token);
    CloseHandle(tokenDuplicate);
    return true;
    }
    }

    }
    if(token!= IntPtr.Zero)
    CloseHandle(token);
    if(tokenDuplicate!=IntPtr.Zero)
    CloseHandle(tokenDuplicate);
    return false;
    }private void undoImpersonation()
    {
    impersonationContext.Undo();
    }
    </script>
      

  4.   

    web.config模拟管理员用户?之前看到过相关的问题...
      

  5.   

    http://support.microsoft.com/kb/306158/
    希望能对你有帮助...
      

  6.   


    谢谢,但是我已经给iis分配过管理员帐号了,也不行。
      

  7.   

    没用过flashpaper
    2k3 下print2flash 转换成功!
      

  8.   

    兄弟,我总算解决了这个win2003 server +asp.net+flashpaper,生成swf的问题了,也折腾了我一天,还好总算调试生成了.....
      

  9.   

    帮忙顶一个2003在vs里调试可以用,但是部署到iis就不行了
    vs里面debug的时候启动flashpaper进程的是administrator,部署到iis里是networkservice,不过貌似调整networkservice的访问权限没什么作用
      

  10.   

    终于测试出一个可行的解决方案。。
    http://blog.csdn.net/razelan/archive/2010/06/08/5655044.aspx
      

  11.   

    那是一定的应该可以通过给networkservice授予某种特定权限来做,不过就涉及到flashpaper的工作流程了
      

  12.   

    为什么不尝试修改flashpaper运行的权限来解决呢?
      

  13.   

    最先尝试的就是修改flashpaper的运行权限和权限模拟,都挂了猜想问题可能是因为 networkservice本身没有打印权限