Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 577 Vote(s) - 3.53 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How do I open a file for edit from the command line under Windows?

#1
How do I open a file for `edit` from the command line under Windows?

Mainly I am looking to open the file in the default editor associated for it (not to be confused with default action for this filetype).

This is different than just "executing" the file, so `start filename` is not a solution.

Note: this would require to use ShellExecute in one way or another.

Update: I added `Python` as an alternative to `batch`.
Reply

#2
Here is a sample Python script that opens a file for edit, if there is an editor assigned to its filetype.

import os
from ctypes import c_int, WINFUNCTYPE, windll
from ctypes.wintypes import HWND, LPCSTR, UINT
prototype = WINFUNCTYPE(c_int, HWND, LPCSTR, LPCSTR, UINT)
paramflags = (1, "hwnd", 0), (1, "text", "Hi"), (1, "caption", None), (1, "flags", 0)
MessageBox = prototype(("MessageBoxA", windll.user32), paramflags)

filename = "readme.txt"
os.startfile(filename, "edit")

try:
os.startfile(filename, "edit")
except WindowsError, e:
MessageBox(text=str(e))
Reply

#3
64 bit Windows does not support edit command.

[To see links please register here]


To open file in with default associated app, in CMD use `start <<file_path>>`
Reference:

[To see links please register here]


To open a file in notepad, in CMD use `notepad <<file_path>>` in CMD
- if file is not associated with default app to open - error will be displayed
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through