How to restore bat file execution from explorer on XP - windows

some bat files need to be launched at the start of the session, but they don't.
Actually, when trying to launch one from the explorer, it opens the Open with window instead of just runnig.
However, the bat files still run correctly from the command prompt.
I bet it has been caused by a virus, but the antivirus did not detect anything unfortunately.
Any idea?

Use the Open With command, select cmd.exe, then before you hit OK, check the box that says "always use this program to open this type of file" or something similar.
If cmd.exe is not in the choices, browse to c:\windows\system32, and cmd.exe should be in there.

You can re associate the extension by downloading the reg file for batch from the link below which should solve your problem.
http://www.dougknox.com/xp/file_assoc.htm

Related

What is the difference between opening application by cmd/ps or by click?

I try to copy mozilla firefox bookmarks/passwords into a new windows profile during the login either by cmd or powershell, without copying the whole firefox profile: The script opens firefox (to create a profile), closes firefox and overwrite the created bookmarks with the old ones.
Problem:
The user opens firefox and in this moment firefox deletes the copied bookmarks/passwords and creates new ones.
In case the user opens and closes firefox manually, bookmarks/passwords can be copied by script and everything is fine.
Obviously there is a difference how Windows is handling files when opening by click or by cmdlet / powershell.
Commands I tried to open firefox:
[PS] Start-Process "C:\Program Files\Mozilla Firefox\firefox.exe" -PassThru
[CMD] start "" "C:\Program Files\Google\Chrome\Application\chrome.exe"
[CMD] "C:\Program Files\Mozilla Firefox\firefox.exe"
How can I imitate the opening of the application as if it is opened manually by the user?
Regards
You technically can't statically analyze how Explorer opens something because of shell extensions but that is unlikely to apply to .exe files so let us ignore that for now.
How does cmd.exe and batch files launch a process? CreateProcess.
How does Explorer launch a file? ShellExecuteEx most of the time.
That being said, in the case of .exe files, ShellExecuteEx might append to %path% and some other minor things but in the end it is going to end up calling CreateProcess to start the actual process.
I believe your problem is somewhere else, not in the difference between cmd.exe and Explorer.
The files are locked because someone (Firefox still running?) has a open handle to the bookmarks?
It could be a problem related to wrong the current directory? The current directory is locked by Windows so you can't replace it by deleting it.
Firefox running update task started by the task scheduler during login at the exact same time as your login script?
You can get PowerShell to use ShellExecuteEx by setting UseShellExecute to $true before starting the process but according to this it is already true by default (assuming your PassThru parameter does not force it to false).

How do I execute OneNote UWA from Windows command-line?

I can't figure out how to start the OneNote UWA from Windows command-line. The best I could do is find where it's installed. However, I don't know how to actually start it up from the command-line; as, the executables in that directory don't start OneNote UWA.
C:\Program Files\WindowsApps\Microsoft.Office.OneNote_16001.11901.20096.0_x64__8wekyb3d8bbwe
PS: I tried to use the same command-line that's in Windows TaskManager (below). However, the app doesn't startup nor does it give an error; even with elevated privileges.
"C:\Program Files\WindowsApps\Microsoft.Office.OneNote_16001.11901.20096.0_x64__8wekyb3d8bbwe\onenoteim.exe" -ServerName:microsoft.onenoteim.AppXxqb9ypsz6cs1w07e1pmjy4ww4dy9tpqr.mca
I'd really appreciate any help suggestions to do this. If this is not possible (or nobody knows the answer, I would also be happy if someone knows how to associate a global hotkey to OneNote UWA.
I followed this tutorial and it worked great for me:
Launch Metro app from command line
my resultant command was this:
explorer.exe shell:AppsFolder\Microsoft.Office.OneNote_8wekyb3d8bbwe!microsoft.onenoteim
which launched into OneNote (metro/winrt/uwa version and not the desktop version)
There is a shortcut you can do that would have worked in my case. When you look at the target of the shortcut you create... instead use this command line tool to get the full target (since you can't copy from the target box in the shortcut properties window) and then use this instead:
explorer.exe shell:<target value>
get the command line tool here:
LNK file parser
careful though because the value wraps when you use the LNK file parser in a command window. You can output the result text from lnk_parser_cmd to a text file to ensure you get the correct value. Their example is:
lnk_parser_cmd.exe shortcut.lnk
you would simply use:
lnk_parser_cmd.exe shortcut.lnk > result.txt
and then you can easily copy and paste the non-wrapped text from result.txt.

Can't find Cmder in program files

I've been having trouble finding the cmder inside windows program files. I wanted to make a shortcut to it so that I can easily access it using windows docker but can't find the location. I only have cmder now pinned on my taskbar but I would like to know it's directory path. Thanks in advance.
I am using windows x64bit
Open a command line window.
Enter "dir Cmder.exe /s"
It's relative to where you installed it. To find out right-click cmder in your taskbar, and you will see that it says "cmder.exe - shortcut", right-click it again and access properties. In the target field you will see your path.

Running a batch file through command prompt - system cannot find the path specified

I am trying to uninstall Oracle on this Windows 7 (64 bit) machine by downloading a standalone tool from Oracle, I need to run a batch file that is supposed to uninstall but I am unable to run it.
I tried to open command prompt as administrator and I am trying to run this as below:
As you can clearly see from the screenshot, I am doing a "dir" on the directory and can clearly see the file right there. Not sure what's going on here.
I also tried to run the batch file by double clicking from Windows Explorer and a terminal window opens and closes quickly but the batch file is not doing what it is supposed to do (it is clearly not executing from Windows Explorer).
Can anyone help me with this?
As theB pointed out above in a comment, this worked for me:
Open the bat file in notepad. I'll bet it starts with #echo off, and
that the error is actually coming from inside the batch file. The
error if the batch file itself wasn't found is 'X' is not recognized
as an internal or external command, operable program or batch file
'Run as Administrator' changes the current directory. See my answer here
Difference between "%~dp0" and ".\"?

File Access takes me to command prompt rather than Explorer

Whenever I go to my command prompt and type a "c:\temp" or any other file/directory, it takes me to the command prompt rather than the file explorer. Can somebody please tell me how I can fix this so that all file/directory access from cmd takes me to the file explorer.
I have a Win2k3 64bit machine. Has this got anything to do with the 32bit/64bit explorer ?
To run Windows Explorer from command prompt you must type name of the executable:
explorer.exe
or just
explorer
To open a certain folder, pass the path as an arguments. Details here:
Command-Line Switches for Windows Explorer (MSDN KB)
See examples.
To open Explorer at the directory where your cmd is operating you can use
start .
and at a parent directory you can use
start ..

Resources