opening directories like "THIS PC" or "NETWORK" from file manager - command

Is it possible to open "THIS PC" or "NETWORK" from the file manager using cmd? If yes, then how

Yes, this is possible:
C:\>explorer shell:MyComputerFolder
C:\>explorer shell:NetworkPlacesFolder
Reference: look here

Related

Powershell vs GUI shortcuts

I have a file named new.txt. Using GUI I can create a shortcut, for example, "new.lnk". When I click on "new.lnk" file, Notepad is opened with the contents of "new.txt" file. When I create the shortcut using PowerShell
NEW-ITEM -TYPE SYMBOLICLINK -TARGET "NEW.TXT" "NEW.LNK"
I can see the contents of the file using
CAT "NEW.LNK"
but the shortcut file is not working in the GUI: it does nothing.
I expect to see the contents in Notepad editor. The properties of the file created using GUI and PowerShell are the same, except for "Start in" information: blank when the short cut is created using PowerShell and with the path file directory when using GUI.
Symbolic link (symlink) is not the same as Windows shortcut. A symbolic link is created on file system level - it says "here's a file with such filename, but the content is actually in this other file". It's size is 0 Bytes, as it just points to other file.
It would be more proper to name the file "new-linked.txt" instead of "new.lnk".
A shortcut ".lnk" is a separate file that is interpreted by Windows shell. It contains a path to the target file (among other additional properties). If you create shortcut from UI and then try cat my.lnk, you'll see the content of the shortcut file itself, not the target file.
For creating a Windows shortcut from Powershell, see How to create a shortcut using PowerShell.

how can i input a file of "access macro" in windows task scheduler?

i want to run a MSAccess-macro (Makro1) automatically using The Windows7 Tast Scheduler.
What do i Need to Input in the following Fields?
"Programm/script" and
"Add Arguments"
I entered already the whole pfad of the macro in "program/script" and it didnĀ“t work.
Thank you for your help:)
You should enter the path to MSAccess.exe in the "Program/Script" field. Here is an example:
"C:\Program Files (x86)\Microsoft Office\Office14\MSACCESS.EXE"
(Adjust this to match the actual path on your pc.)
Top start/open a database automatically, you need to put the path to the database file into the "Add Arguments" field. If you want to run a macro automatically, you should add the /x commandline switch followed by the macro name.
Here is an example for the complete "Add Arguments" field:
"C:\path\to\YourDatabase.accdb" /x "YourMacroName"

Where does Windows PowerShell set $profile?

I would like to move my default "My Documents\WindowsPowerShell" folder. However, when I try this, PowerShell of course can't find $profile. Is there a file or something that I can edit to point PowerShell to a different startup folder?
What I can suggest is that you dot source the file having the content of your profile in the file $profile.AllUsersAllHosts
$profile.AllUsersAllHosts is something like C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1
Related question: Is it possible to change the default value of $profile to a new value?
You could use junction.exe from Sysinternals to make the WindowsPowershell directory a symbolic link to another location (but not a network drive).
You could do this if you wanted to store the profile scripts at C:\POSH
junction.exe "$HOME\Documents\WindowsPowerShell" 'C:\POSH'
As far as i know you can't do that. The user profile location is always under 'My Documents\WindowsPowerShell' and your only option is to relocate your documents folder (folder redirection).
By default $Profile/$Home/$PSModulePath are all within the registry... normally under
HKEY_CURRENT_USER\Volatile Environment for User environment variables
HKEY_CURRENT_USER\Environment for System environment variables
HKEY_CURRENT_USER\Software\Microsoft\Windows\Explorer\User Shell Folders
and elsewhere!

How can I create batch file to run a command?

I've writen this command line successfully:
c:\windows\system32\inetsrv\appcmd set config "Default Web Site" -section:requestFiltering -requestLimits.maxAllowedContentLength:157286400
I want to create a batch file to execute this line.
Any suggestions please?
Create a new text document
Rename it "mybatfile.bat"
Press yes when prompted "If you change a file name extension, the file might become unusable. Are you sure you want to change it?"
Right click on the bat file, "edit"
Put in your command:
c:\windows\system32\inetsrv\appcmd set config "Default Web Site" -section:requestFiltering -requestLimits.maxAllowedContentLength:157286400
Well at the command prompt you could type
copy con myfile.bat
c:\windows\system32\inetsrv\appcmd set config "Default Web Site" -section:requestFiltering -requestLimits.maxAllowedContentLength:157286400
"press F-6"
then enjoy your bat file.
Is this not a setting you could change in a config file somewhere so it is permanent though?

Open text file and program shortcut in a Windows batch file

I have two files in the same folder that I'd like to run. One is a .txt file, and the other is the program shortcut to an .exe. I'd like to make a batch file in the same location to open the text file and the shortcut then close the batch file (but the text file and program remain open).
I tried this with no luck:
open "myfile.txt"
open "myshortcut.lnk"
Also didn't work:
start "myfile.txt"
start "myshortcut.lnk"
I was able to figure out the solution:
start notepad "myfile.txt"
"myshortcut.lnk"
exit
This would have worked too. The first quoted pair are interpreted as a window title name in the start command.
start "" "myfile.txt"
start "" "myshortcut.lnk"
Don't put quotes around the name of the file that you are trying to open; start "myfile.txt" opens a new command prompt with the title myfile.txt, while start myfile.txt opens myfile.txt in Notepad. There's no easy solution in the case where you want to start a console application with a space in its file name, but for other applications, start "" "my file.txt" works.
The command-line syntax for opening a text file is:
type filename.txt
File types supported by this command include (but are not limited to): .doc, .txt, .html, .log
If the contents is too long, you can add "|more" after "type filename.txt", and it will pause after each screen; to end the command before the end of the file, you can hold Ctrl + C.
I use
#echo off
Start notepad "filename.txt"
exit
to open the file.
Another example is
#echo off
start chrome "filename.html"
pause
You can also do:
start notepad "C:\Users\kemp\INSTALL\Text1.txt"
The C:\Users\kemp\Install\ is your PATH. The Text1.txt is the FILE.
"location of notepad file" > notepad Filename
C:\Users\Desktop\Anaconda> notepad myfile
works for me! :)
In some cases, when opening a LNK file it is expecting the end of the application run.
In such cases it is better to use the following syntax (so you do not have to wait the end of the application):
START /B /I "MyTitleApp" "myshortcut.lnk"
To open a TXT file can be in the way already indicated (because notepad.exxe not interrupt the execution of the start command)
START notepad "myfile.txt"
The command start [filename] opened the file in my default text editor.
This command also worked for opening a non-.txt file.
If you are trying to open an application such as Chrome or Microsoft Word use this:
#echo off
start "__App_Name__" "__App_Path__.exe"
And repeat this for all of the applications you want to open.
P.S.: This will open the applications you select at once so don't insert too many.
Try using:
#ECHO off
ECHO Hello World!
START /MAX D:\SA\pro\hello.txt
Its very simple,
1)Just go on directory where the file us stored
2)then enter command i.e. type filename.file_extention
e.g type MyFile.tx
To open a file with default software just need to type the path of the file or, if you are at the file location, the file name.
C:\Users\MyName>C:\User\MyName\Desktop\hello.txt
or
C:\Users\MyName\Desktop>hello.txt
If you want specific program like notepad you can specify it first.
C:\Users\MyName>notepad C:\User\MyName\Desktop\hello.txt
or
C:\Users\MyName\Desktop>notepad hello.txt
Note that notepad is usually default text editor for .txt, in this case would make more sense to type notebook only to open a .cs/.cpp/.py file if your default for that files is any IDE and you just want to see the file on notebook
Regarding the batch file it will work the same way but to open them at the same time and let the command line go away you should use:
start "title" {filename}
So the command can open the file and return to next line immediately.
start "" C:\Users\MyName\MyFolder\foo.exe
start "" C:\Users\MyName\MyFolder\notes.txt
or
start "" foo.exe
start "" notes.txt
The last one only works if the batch file is on the same location of the files.
If you plan on using the console to open the batch file and you want the console to close at the end you should indeed write exit on last line.
When in doubt, it always helps to read the docs:
>help start
Starts a separate window to run a specified program or command.
START ["title"] [/D path] [/I] [/MIN] [/MAX] [/SEPARATE | /SHARED]
[/LOW | /NORMAL | /HIGH | /REALTIME | /ABOVENORMAL | /BELOWNORMAL]
[/NODE <NUMA node>] [/AFFINITY <hex affinity mask>] [/WAIT] [/B]
[command/program] [parameters]
"title" Title to display in window title bar.
path Starting directory.
B Start application without creating a new window. The
application has ^C handling ignored. Unless the application
enables ^C processing, ^Break is the only way to interrupt
the application.
I The new environment will be the original environment passed
to the cmd.exe and not the current environment.
MIN Start window minimized.
MAX Start window maximized.
SEPARATE Start 16-bit Windows program in separate memory space.
SHARED Start 16-bit Windows program in shared memory space.
LOW Start application in the IDLE priority class.
NORMAL Start application in the NORMAL priority class.
HIGH Start application in the HIGH priority class.
REALTIME Start application in the REALTIME priority class.
ABOVENORMAL Start application in the ABOVENORMAL priority class.
BELOWNORMAL Start application in the BELOWNORMAL priority class.
NODE Specifies the preferred Non-Uniform Memory Architecture (NUMA)
node as a decimal integer.
AFFINITY Specifies the processor affinity mask as a hexadecimal number.
Picture for the visual learners: