0
Dim si As New System.Diagnostics.Process()
si.StartInfo.WorkingDirectory = tortoisesvnsetupfilefolder
si.StartInfo.UseShellExecute = False
si.StartInfo.FileName = "cmd.exe"
si.StartInfo.Arguments = "/C START /W TortoiseProc.exe /command:update /path:""& project path&"" /closeonend:1"
si.StartInfo.CreateNoWindow = True
si.StartInfo.RedirectStandardInput = True
si.StartInfo.RedirectStandardOutput = True
si.StartInfo.RedirectStandardError = True
si.Start()
si.WaitForExit()

when i run this code in visual studio it work but when I create website in IIS and run project process start not work it service started but stay active in task

i am using same computer 1. when i am run project in visualstudio and this code run perfect and fast and updated respository 2. problem is in IIS i created website under IIS for same project and when i run project of IIS this is not working upto si.Start() code is work and it start tortoise client service and this service remain active(in taskmanager ) and not complete after si.Start() nothing happen it remain active no response of process

Jas
  • 61
  • 1
  • 6
  • 1
    Usually an IIS app pool runs as a different user. That user is going to have a separate session from your user (or no session, I'm not quite sure). So I wouldn't expect it to be able to launch an app that you can interact with on your desktop, at least not without something to somehow launch the app in your session. Why does your web application need to launch Notepad in the first place? – mason Jul 19 '22 at 13:49
  • Well when you run as local then of course you see notepad since your running on the same computer as the web server. If you run on a web server, then your browser and you are on a different computer. Note pad is launch just fine, but it's launching and displaying in the web server of which no one can see. Kind of like when people start using msgbox in their code - on your local computer the msgbox looks like it works because the web server, and desktop is the one same computer. With web server you can launch notepad, word etc. , that's going to launch on the web server computer - not client – Albert D. Kallal Jul 19 '22 at 17:14
  • So any desktop program will run as desktop, but that desktop is on the web server, not your computer. You not at all grasping the architecture here. I can't see nor use desktop programs launched on the server and you only see such programs if you are sitting in front of the web server screen and keyboard. But web server dishes out web pages to users and their browser. You can't see nor run desktop programs on the server and expect to see such programs on the desktop that's running a browser – Albert D. Kallal Jul 19 '22 at 17:19
  • There are essential differences you should learn about web apps on IIS https://halfblood.pro/web-application-differences-in-visual-studio-and-iis-60fec7e311b3 So you cannot assume things work the same way as in desktop apps. – Lex Li Jul 20 '22 at 01:23
  • @mason there are many good materials on Windows session isolation, so that you can learn what is session 0 (IIS runs there), https://techcommunity.microsoft.com/t5/ask-the-performance-team/application-compatibility-session-0-isolation/ba-p/372361 – Lex Li Jul 20 '22 at 01:26

1 Answers1

0

Well when you run + launch notepad as local AND ALSO are running the web server local (such as during development), then of course you see notepad since your running on the same computer as the web server.

If you run on a real web server, then your browser and you are on a different computer. Note pad is WILL and DOES launch just fine, but it's launching and displaying in the web server of which no one can see!!!!

So, on YOUR desktop and YOUR computer, you are running both IIS, and note pad. So, during development mode and phase - this looks to work ok.

But you cant redirect windows programs out to a browser. (windows programs have direct use of your graphics card).

But, if you launch note pad on the SAME computer running the web server? (which you are doing!!!). Then note pad will launch on the web server, and NOT your computer.

If you were able to walk over to the web server, you will see note pad launched and running on that server. But, you can't see nor use such desktop programs on your client side computer - which is only running a browser.

So, you can't for example launch a process on MY computer that hits YOUR web site!

EDIT: user understands that this is to run on the server side, and run on the web server console.

Well, had a chance to spool up a real server running IIS. And I can confirm that the code above will not work on the real server.

And the reason?

IIS on a server is running as a service, and on servers, they are not allowed to shell out. The permissions used to exist to do this, but from what I can tell, now they don't.

EVEN if you set the app pool to run as the server administrator account (very bad idea), I found that the code would not work.

So, to make this work? well, you can do some serious chopping and changing on the actual web server - and you have to mess around with a lot of rights to do this.

I don't have a great answer, but a bit of googling, and we see that this in general is not allowed anymore.

So, it might depend on what version of server you have. Quite sure this hole was closed around 2012 version (10 years ago).

You can try some of the ideas here:

Foo.cmd won't output lines in process (on website)

(but, even above link is 10+ years ago - and now out of date).

Albert D. Kallal
  • 42,205
  • 3
  • 34
  • 51
  • i am using same computer 1. when i am run project in visualstudio and this code run perfect and fast and updated respository 2.problem is in IIS i created website under IIS for same project and when i run project of IIS this is not working upto si.Start() code is work and it start tortoise client service and this service remain active(in taskmanager ) and not complete after si.Start() nothing happen it remain active no response of process – Jas Jul 20 '22 at 06:18
  • Ok - as long as you grasp this runs server side, then no problem. I have IIS in a server VM, and tomorrow I'll try this from vs - which you note works, and then from a real server running IIS. This might be permissions, since with IIS your running as iis_user. – Albert D. Kallal Jul 20 '22 at 06:47
  • see my edit above - I don't think you can make this work on the production server. – Albert D. Kallal Jul 21 '22 at 03:52
  • even if this is the same computer, when you launch + run reall IIS, then the app_pool is now running under IIS_user, or now day AppPoolIdentity. You could try changing that app_pool and set the user to the current computer logon. But, because IIS is running as a service, then restrictions still exist. On a real server, EVEN if I add a new user, and use that for app_pool, that service still can't launch such windows programs. – Albert D. Kallal Jul 21 '22 at 14:40