Reopening the taskbar (explorer.exe) after it has been killed? - c#

I'm writing a small program to fix compatibility issues with a 16-bit program. This fix is to close explorer.exe, as explorer overrides some of the palettes in the program. Afterwards, we reopen explorer.
When using a .bat file, it works:
#ECHO OFF
taskkill /f /IM explorer.exe
EmStraditionX.exe
start /B explorer.exe
This method isn't ideal, as it requires extra files to download. For the sakes of simplicity, assume that it is impossible for me to distribute more than the C# compatibility program.
My first thought was to just Process.Start("explorer.exe"), but this did not work, and instead just opened the 'Libraries' folder in an explorer window, without making the taskbar visible again.
I then tried to use the same command as the batch file, except like this: Process.Start("cmd.exe", "/C start /B explorer.exe"), which again did not work.
Does anyone know how I can reopen the taskbar from C#?
Thanks,
Ruirize.

Use:
Process.Start(Environment.SystemDirectory + "\\..\\explorer.exe");
Putting the full path will make it work
Martyn

Do you use also "Run As Administrator" function in compatibility options?
If you do - you will start explorer from another session and you cant see window,that is running in other (administrator) session.

Related

Open Babel running .Net C# Process, doesn't work on deployed website

Due to some circumstances, I was ask to develop a page that uses Process in .Net C# to call the function through command prompt.
The code works perfectly Fine on visual studio, but when deployed on an IIS server. the Process doesn't seems to work, I've debugged and find out the process itself works. but the open Babel command doesn't work, i did double check and the identity i supply with should be alright, i did even supply it with admin privilege but still doesn't work. it doesn't even pop or error, it just simply ignored it and go through the commands.
I put the command into a .bat file, with some extra command to test if the .bat works. everything is fine until the command with open babel, then process just doesn't seem react with the command.
obabel %1 -O %2 --gen2d
this is the command i supply it with, %1 is the input file while %2 is the output file name. A very simple conversion. Note: everything is fine, just only the open babel command got ignored in the entire file. and I've tried to supply it with admin privilege, still doesn't work. the open babel can be used if directly used with command prompt on the server, or through visual studio. but it doesn't work if i deployed it through IIS server.
Found the solution, after all kinds of modification.
it seems like i have to provide a physical path to Open Babel.exe in the .bat file, and same as the parameter file i supply it with.
It's risky solution, but at least it solves the problem.

why am I getting this error during a build ? mentions something about cannot debug

I am trying to run/debug a project and im getting this error. I have never seen this before!
Severity Code Description Project File Line Suppression State
Error Unable to copy file "obj\Debug\Side_Project.exe" to
"bin\Debug\Side_Project.exe". The process cannot access the file
'bin\Debug\Side_Project.exe' because it is being used by another
process. Side_Project
As the error states it cannot copy the file because its in use. its as simple as that.
Make sure the file isn't actually running, Check Task Manager.
Make sure it isnt being locked by your virus checker.
Also try restarting visual studio
If worst comes to worst restart your pc
Job done, happy debugging
This means the program is still opened. Check if it is running in the background, open task manager or force kill it with Command Prompt
command:
C:>Taskkill /IM Side_Project.exe /F
or by PID
C:>Taskkill /PID (PID HERE) /F
View your PID by opening a list of running tasks with
C:>tasklist
See if that works.

Can I open two solutions with Visual Studio for Mac at the same time?

That's it. Can this be initiated two times to open two separated solutions at the same time?
By default an .app runs as a single instance/single document mode, its the Cocoa way of life and MonoDevelop/Xamarin Studio/Visual Studio for Mac follow that paradigm.
From the cmd line:
Open a solution in an existing running instance or starts the first instance:
open MySolution.sln
Open a solution in a new instance of the application:
open -n MySolution.sln
-n = Open a new instance of the application(s) even if one is already running.
GUI-based:
From #TomGilder comment:
MS Solution Launcher
Ref: https://github.com/Redth/MSSolutionLauncher
You can do this in the IDE when an existing solution is open by deselecting Close current workspace when you open the solution through the File -> Open menu:
Open terminal and run the command:
open -n -a "Visual Studio"
As a short cut I create a simple automator application that runs a bash script to open a new instance. You can do this with most Apps.
open -n /Applications/Visual\ Studio.app
When done save your automator application I usually call it "VSMac Clone" and give it a funky icon.
You can use the one I created at your own risk VSMac Clone
First, open your first solution
go to files and then recent solution then find your solution
ctrl+tick on that solution you want to open

C# Process.Start() Dialog Box for BAT file

I have a C# program that needs to spawn a .BAT command file during its execution. No problem. I can just use (for example)...
System.Diagnostics.Process.Start("PublishFeed.bat", "file.xml");
...in order to run the cmd with a parameter. In the debugger, this works fine. However, when I run the executable in production, Windows pops up a dialog box that says "Do you want to open this file? Name: PublishFeed.bat Type: Unknown File Type.
If I click OK, it runs fine.
Why is this dialog appearing? Seems especially odd for it to claim Unknown File Type, when clicking OK seems to run the BAT file with no problem.
thanks all!
P.S. Yes, I can probably remove the need for the BAT file, but I would still like to understand the issue.
I think the most reliable way to do this is to just speficy to open that batch with cmd:
System.Diagnostics.Process.Start("cmd", "/c PublishFeed.bat file.xml");

how do i start explorer using process class in c#

i have replaced windows shell with my application it worked perfectly, after closing my application i have to launch windows explorer with the following piece of code
Code to start explorer
Process.Start(#"c:\windows\explorer.exe");
Registry key i have used to replace shell
HKEY_Local_Machine\Software\Microsoft\WindowsNT\CurrentVersion\WinLogon\Shell
it doesnt show taskbar and start menu, it just shows mydocuments folder. I need start menu and taskbar while after explorer started
My guess is that since explorer isn't defined as the shell, it won't run as the shell. I think that you'd have to change the registry settings to make explorer the shell again before you run it.
So, as you wrote you replaced the shell in the registry with your own version. So it's up to you to show a start menu, etc. If you like to start a explorer and let it act as a shell, go on and replace the entry in the registry with the old one.
Due to the fact, that you like to be the shell again, next time windows starts, maybe the following trick will do it:
Prerequisities:
Place your program in registry as shell and start windows
Your program runs and wants to start explorer as shell
Action to to:
Replace entry in registry against entry containing explorer as shell
Start the explorer
Replace entry in registry back to your app as shell programm
Wait till next boot...
You will probably have to kill the existing shell process (i.e. your app) before starting explorer again.

Categories

Resources