Showing posts with label windows. Show all posts
Showing posts with label windows. Show all posts

Friday, 7 February 2014

Some batch file commands

Funny but I've tried to change directory in a command prompt by simply typing:

CD D:\
and sure enough this does not work.
To change to new directory add /D  (case insensitive)
 
cd /d  d:\
 or just
D:

Some reserved variables:

%~dp0  -> this will contain the path to the script
%0      -> this will hold the path+the name of the script

%1 up to %9   -> this in the script will pick up arguments that may have been passed to the script when it was launched from command line


Tuesday, 26 March 2013

Run command prompt on remote Win machine

Install Sysinternals Process Utilities from:

http://technet.microsoft.com/en-us/sysinternals/bb795533

 PsExec  Execute processes remotely.

The following command launches an interactive command prompt on \\marklap:
psexec \\marklap cmd
This command executes IpConfig on the remote system with the /all switch, and displays the resulting output locally:
psexec \\marklap ipconfig /all
This command copies the program test.exe to the remote system and executes it interactively:
psexec \\marklap -c test.exe
Specify the full path to a program that is already installed on a remote system if its not on the system's path:
psexec \\marklap c:\bin\test.exe

 

Process Explorer Find out which process locks a resource (Find menu), what files, registry keys and other objects processes have open, which DLLs they have loaded

 

Friday, 15 February 2013

How to run minimized batch file as a scheduled task

In Windows, Task scheduler, Properties of the task, Actions tab, edit the task by adding:

%comspec% /c start /min 

in front of the path to the script, in the field "Program/Script" where you would browse to the script on your system, for example

%comspec% /c start /min "C:\path\to\my\batchfile.bat"

%comspec% is an environment variable that points to the location of the cmd.exe on your system.

Clicking OK will invoke dialog to ask if you if you ment all this to be parameters or not. Answer NO and the task will be saved as you would expect.
 Then, add

exit

at the end of the batch file that you want to run with minimized with Task scheduler.


That's all.