PsExec

Execute processes on a remote system and redirect output to the local system

PsExec is a command-line tool that lets you execute processes on remote systems and redirect console applications' output to the local system so that these applications appear to be running locally. You can download PsExec for free from the Sysinternals website. Here are some advanced tips and tricks to help you leverage the full potential of PsExec as a systems management utility.

Related: PsExec, User Account control and Security Boundaries

The PsTools Suite

PsExec is a member of Sysinternals' PsTools suite, which contains 11 tools. To be in the suite, tools must conform to a set of specifications that includes supporting Windows NT 4.0 and later, being a console application, and having the ability to work on the local system as well as on a remote one. PsTools utilities require no manual installation of software on the remote system, and they let you specify alternative credentials to access the remote system.

Incidentally, the reason that the suite is named PsTools and that all the member tools have Ps as a prefix to their name is that the first tool I developed that satisfied the listed criteria was PsList, a program that lists running processes. I named the tool after the ps utility that performs the same function on UNIX systems.

Related: PsExec to the Rescue

As with many of the tools in the PsTools suite, PsExec's ability to run processes remotely requires that both the local and remote computers have file and print sharing (i.e., the Workstation and Server services) enabled and that the default Admin$ share (a hidden share that maps to the \windows directory) is defined on the remote system. The reasons for these requirements will become clear later when I describe how PsExec works.

PsExec

PsExec's ability to run processes remotely with no manual installation of software on the remote system makes deployment easy. However, if PsExec were only able to launch a program on a remote system, its usefulness would be limited. PsExec's ability to redirect the input and output of console applications is what makes the tool a versatile systems management utility. Figure 1 shows PsExec's command-line options and gives a hint as to its capabilities. Many Windows administrative console tools can run only on a local machine. PsExec lets you remote-enable any of them. For example, PsExec lets Ipconfig, the Windows utility that displays the TCP/IP configuration for a system's network adapters, show a remote system's configuration. A sample command for that use is

psexec \\remote ipconfig

where remote is the name or IP address of the system you want to query. You'll see Ipconfig's output as if you had run Ipconfig on the local machine.

If you don't specify the path of the program you want to execute, PsExec looks in the \windows\system32 directory of the remote system. If you know that the program isn't in that directory, enter its full path on the remote system; if it's an executable on the local system that you want to execute on the remote system, specify the -c switch and the file's local path. The -c switch directs PsExec to copy the specified executable to the remote system for execution and delete the executable from the remote system when the program has finished running.

An even more powerful use of PsExec's console-redirection capability is to run a command prompt on a remote system as if the command prompt were running locally. This use of PsExec is similar to running a Telnet client on the local machine and connecting to a Telnet service on the remote machine, but you don't need to have the Telnet service, or any other special service, running on the remote system. Simply execute the command:

psexec \\remote cmd

If you want to execute one console command on the remote system, pass the command prompt the /c switch followed by the command you want to execute. For example, the command

psexec \\remote cmd /c ver

displays the Windows version number of the remote system on the local machine's console.

Another popular use of PsExec is to deploy hotfixes or other patches that support a noninteractive interface across your network. To make this task even easier, PsExec takes multiple computer names, the name of a text file containing a list of computer names, or the special name of \\* that results in an enumeration of all the computers in the current domain. For instance, to execute the Microsoft MyDoom removal tool on computers named Remote and Remote1 and log the exit status of the cleanup to a file, you could use the command

psexec \\remote,remote1
        -c doomcln.exe
        -s 2> results.log

Upon exit, a process specifies an integer that the process's parent process can read. Programs often use the exit code to report the success or failure of their execution. Whenever a process executed with PsExec is completed, PsExec displays the process's exit code and returns the exit code as its own exit code. You should test a program's behavior or check its documentation to determine what that program's specific error codes mean, but an exit code of 0 typically means success. The -s switch specifies that PsExec should execute the command under the System account. I'll discuss this option more in a moment.

PsExec Security

You should be aware of several ways in which PsExec interfaces with Windows security. By default, the process you execute on the remote system impersonates the account from which you run PsExec on the local system. Impersonation is somewhat restricted from the perspective of security—the remote process doesn't have access to any network resources, even those that your account typically would be able to access. If the account in which you're running doesn't have local administrative privileges on the remote system, the process you want to run requires access to network resources, or you want to run a process in a different account, then use PsExec's -u switch to provide an alternative account name. For example, you could enter the command

psexec \\remote

-u remote\administrator

-p adminpass ipconfig

to run Ipconfig under the Administrator account on the remote machine. Use the -p switch to enter the password for the account you specified with the -u switch. If you omit the -p switch, PsExec prompts you to enter the password (for security reasons, PsExec doesn't echo the password you enter to the screen).

If you specify alternative credentials, the remote process runs with those credentials and will have access to network resources that the alternative account can access. To run in a different account, PsExec must use that account to log on to the remote system. PsExec therefore requires the password on the remote system and sends the password in clear text from the local system. You need to be aware of this fact if unauthorized network sniffers could intercept traffic between the local and remote system.

You can also run the remote process in the System account, under which Windows services and core Windows processes, such as Winlogon and the Local Security Authority Subsystem Service (LSASS) are executed. The System account has powerful privileges. Some file-system and registry resources have default security settings that permit access only from the System account—examples are the HKEY_LOCAL_MACHINE\SAM registry subkey and the \System Volume Information directory that's present on each volume of all Windows 2000 or later systems.

For example, if you've ever been curious about the contents of the SAM subkey, which appears empty in regedit because regedit can navigate the subkey only under the System account, you can use PsExec similarly to the way you use the Runas command (which is available on Win2K and later) to run regedit under the System account. The command is this:

psexec -s -i

c:\windows\regedit.exe

Note that the command doesn't include a remote computer name and does include the -i (interactive) switch. When you enter the command, regedit will appear on your desktop running in the System account, and you'll be able to look inside the HKEY_LOCAL_MACHINE\SAM and HKEY_LOCAL_MACHINE\SYSTEM subkeys. The -i switch is what causes regedit to appear on the console desktop, and it's typically useful only when you want to run a GUI application on the local system where you can interact with it.

A last security note relates to viruses. Several viruses use PsExec to propagate within a network, and as a result, several major antivirus products flag PsExec as a Trojan horse program or a worm. Remember that PsExec works on remote systems only if it runs within an account that has administrator group membership on the remote system. In other words, unless the account from which you run it has administrative access to a remote system, PsExec won't be able to execute a process on the remote system. In addition, PsExec's functionality can be achieved in other ways; thus, PsExec is only a convenience for virus writers, who could otherwise easily implement the functionality that PsExec provides.

Inside PsExec

PsExec starts an executable on a remote system and controls the input and output streams of the executable's process so that you can interact with the executable from the local system. PsExec does so by extracting from its executable image an embedded Windows service named Psexesvc and copying it to the Admin$ share of the remote system. PsExec then uses the Windows Service Control Manager API, which has a remote interface, to start the Psexesvc service on the remote system.

The Psexesvc service creates a named pipe, psexecsvc, to which PsExec connects and sends commands that tell the service on the remote system which executable to launch and which options you've specified. If you specify the -d (don't wait) switch, the service exits after starting the executable; otherwise, the service waits for the executable to terminate, then sends the exit code back to PsExec for it to print on the local console.

Discuss this Article 144

Anonymous User (not verified)
on Mar 15, 2005
RE: The credentials supplied conflict with an existing set of credentials.can anyone please solve this problem This usually happens when you already have a share to the computer with a different user account. For instance if your account has a share to this computer and your psexec line uses a different account. Use NET USE to list all your existing shares and DELETE the one you are trying to connect with.
Anonymous User (not verified)
on Apr 7, 2005
since NAI detected PSEXESVC as a virus and tried to remove it, psexec falis to start on those servers. The windows event log reported Event ID 7000, the system can not find the file specified.
Ronald (not verified)
on Sep 6, 2007
I'm trying to run the PSExec Tool on a remote server in order to change the System Time. Problem is, this process is being called within a simple bat script and I have concerns exposing sensitive data, such as, Server's Administrator UserName and Password in clear text. I'm trying to run this tool using a regular user account modified with elevated privileges. I believe the only Privilege Usage requirements needed to execute this task are as shown below. As a result, I added the corresponding User Right Assignments to Joe user hoping that would solve the issue. Sadly though, this did not work. Am I missing something else or is my requirement not possible? Thx. Ron SeAssignPrimaryTokenPrivilege (Replace a process- level token) SeCreateTokenPrivilege (Create a token object) SeLoadDriverPrivilege (Load and unload device drivers) SeTakeOwnershipPrivilege (Take ownership of files and other object) SeRestorePrivilege (Restore files and directories) SeSystemEnvironmentPrivilege (Modify firmware environment variables) SeSecurityPrivilege (Manage auditing and security log) SeTcbPrivilege (Act as part of the operating system) SeBackupPrivilege (Backup files and directories) SeSystemtimePrivilege (Change the system time)
Anonymous User (not verified)
on Mar 2, 2005
You have to set quotes befor "cmd.exe until the end of the script
ngadgilwar
on Feb 22, 2012
I am trying to give some db2 command from my local system to remote system using psexec, then those commands are not getting executed on that remote server. But if I give normal Windows commands like mkdir from my local system to remote system using psexec, then they are working properly.
Anonymous User (not verified)
on Jul 16, 2005
Scanstate errors out on a remote machine when run with psexec using the '-d' switch. Without the '-d' it works fine, but I plan to backup multiple machines remotely and want to be able to do this asynchronously and not have to wait for each scanstate session to finish as is the case here. I'm running this on XP SP1/2 and get a memory reference error (which I could provide later). Scanstate takes about 20 minutes to run, but the error seems to happen within a minute or so, so it doesn't appear to be a timeout issue (I can run xcopy with psexec -d for about 20 minutes without a problem). Any ideas most welcome. Thanks
Anonymous User (not verified)
on Aug 17, 2005
When trying the psexec with the -i switch on a remote Windows XP machine I get the following error: Not enough quota is available to process this command. anyone knows how can I solve this? thanks
Anonymous User (not verified)
on Apr 22, 2005
psexec \\mach1 -i -d -s -f -c -w C:\scripts "C:scripts\CheckoutandBuildMyApps.bat" This command works if the file does not exist on the remote machine. If the file exists, it is supposed to force copy the file (-f option) to the remote machine. It executes the older version of the script and does not state that it has failed to copy the file. Any Clues? Thanks in advance.
Anonymous User (not verified)
on Mar 15, 2005
psexec has gone crazy on my system. It repeats the command in an infinite do-loop until I control-c to stop the batch file. However, if I type in another psexec command, it goes right back to the "stuck" one & loops again. This behavior survives reboots. My system is still executing a psexec command that I typed in a week ago & will not recognize any new psexec command input. How do I stop it?
jharrington
on May 16, 2005
I have been using psexec with Windows 2000, but when I use it with Windows 2003 server, jobs that use mapped drives fail. See the examples below. Example 1 is a mapped network drive and Example 2 is a local drive. Is there any way I can make this work with Windows 2003? Thanks! ********* EXAMPLE 1 ************************ C:\Xformer>psexec \\transform4 -s -u administrator -p xxxxxxxxxx cmd /C dir s: PsExec v1.58 - Execute processes remotely Copyright (C) 2001-2005 Mark Russinovich Sysinternals - www.sysinternals.com The system cannot find the path specified. cmd exited on transform4 with error code 1. ********* EXAMPLE 2 ************************ C:\Xformer>psexec \\transform4 -i -u administrator -p xxxxxxxxxx cmd /C dir d: PsExec v1.58 - Execute processes remotely Copyright (C) 2001-2005 Mark Russinovich Sysinternals - www.sysinternals.com Volume in drive D has no label. Volume Serial Number is 8456-8877 Directory of d: 05/15/2005 04:28 PM temp 05/13/2005 03:05 PM WUTemp 0 File(s) 0 bytes 2 Dir(s) 23,378,264,064 bytes free cmd exited on transform4 with error code 0.
Anonymous User (not verified)
on Mar 21, 2005
it's one of the best tools I've ever used. I can even read/write Windows EFS encrypted files on a remote machine from the local screen!
Anonymous User (not verified)
on May 9, 2005
hi, i have the same problem than jcmpinto, the psexec command says : The process tried to write to a nonexistent pipe .... :( i call the psexec command in a java program : cmd /c C:\psexec \\10.66.X.X -u myuser -p mypasswd -i -w F:\Naming\ F:\Naming\NewTest.bat and the biginnig of the .bat is : set PATH=.;bin;..\shared\orbacus_v4.0.4_patched5;..\Imr\bin;..\utils;%PATH% set CONFIG=..\config\orbacus.config FOR /f "delims=" %%a in ('CD') DO SET CWD=%%a nameserv.exe --version 2>db\version.txt for /f "delims==" %%i in (db\version.txt) DO set l=%%i title Installation of %l% ...
Anonymous User (not verified)
on May 12, 2005
We use PsExec as a 3rd tool with our product to remote deploy software's over the network. The command we pass to PsExec psexec \\10.10.51.26 -u 10.10.51.26\test -p test -c -f -i -e test.exe We prepend the user name with the machine when the domain name in not provided. If the domain is provided we just use the domain administrator’s user name for remote deployment. One of our customer does not wants give domain admin user and pwd. So as a test fix we remove the machine name from the user name psexec \\10.10.51.26 -u test -p test -c -f -i -e test.exe Now the remote deployement fails. Just wanted to know which is the correct option to pass to psexec if the machine is in a domain. psexec \\10.10.51.26 -u 10.10.51.26\test -p test -c -f -i -e test.exe or psexec \\10.10.51.26 -u test -p test -c -f -i -e test.exe or psexec \\\\10.10.51.26 -u test -p test -c -f -i -e test.exe
Anonymous User (not verified)
on Aug 25, 2005
How to create admin$ share remotely which is must for running the psexec....any help would be highly appreciated...Thanx....Mohit.
bhatia (not verified)
on Apr 19, 2005
Hello, I am using psexec from a remote computer (c code). fprintf(pt,"psexec \\\\recon1 -u administrator -p sparky -i d:\\\\reconparallel.exe\n"); fprintf(pt,"psexec \\\\recon2 -u administrator -p sparky -i c:\\\\reconparallel.exe\n"); I write this command in a file and run that file. Its working fine. The only thg is that it runs the command on recon1 1st, completes the command, and then run the command on recon2. Since the 1st command take like 6hrs to complete, I wanted to know if there is a way when it runs both the command at the same time on 2 different comouters (recon1 and recon2)? Thnaks
FabienTeulieres
on Sep 18, 2012
The "PS tools" suite is just brilliant, Mark. I use it daily in our organization's remote automation routines. After a few tweaks, it runs flawlessly. I can't thank you enough for this great product * 5 stars *
nilakshi (not verified)
on Nov 24, 2008
PsExec is gr8!!! further, I need to know how can i use autocomplete of folder names, etc. while using cmd on remote machines.. thanks
Anonymous User (not verified)
on Apr 1, 2005
I'm getting "The system cannot find the file specified" when I attempt to run a vbscript. Ipconfig and other commands do run properly on the same computer.
JamesLewis
on Jul 3, 2012
HI, I have been using PS EXEC to remotely kick of numerical models on a network computer. We can communicate with the remote computer and view ipconfig, etc. We can kick off the models if all the files are located on that remote computer, however if the source files are located on yet ANOTHER mapped network computer, the PS EXEC function has trouble communicating. Has anyone had any similar problems? ie communicating with mapped network drives on the remote computer.
Anonymous User (not verified)
on Feb 24, 2005
I loved this little utility that does all. what does mean when I get the following error: Defrag.exe exited on computername with error code 0? almassud@hotmail.com thanks
Anonymous User (not verified)
on May 4, 2005
PsExec rocks. What would make it rock even more is if one could specify a foreground/background color for the interactive command prompt. That way there would be a CLEAR indication that one was working on a remote system. Then when the PsExec ends, the prompt could go back to the original colors...
Anonymous User (not verified)
on Apr 18, 2005
I am totally new to this tool, but using it to run MS patches. I choose to run this on the remote system(s) using yhe -i, and everthing starts. How do I get the patch to finish and answer the prompts ("next" Finish" etc..) If I run w/o the user intervention (-i)on the client, the psexec tool appears to hang. I assume this is because it is waitng for input. Any help would be helpful
Anonymous User (not verified)
on Mar 8, 2005
I want to use a batch file to automatically open CISCO VPN client and enter user name and password
Shuaib (not verified)
on May 15, 2009
I am getting the following error code 0. Any idea how to fix this? C:\WINDOWS\system32>psexec \\2.75.221.2 -u administrator -p watchThis ipconfig PsExec v1.95 - Execute processes remotely Copyright (C) 2001-2009 Mark Russinovich Sysinternals - www.sysinternals.com ipconfig exited on 2.75.221.2 with error code 0. C:\WINDOWS\system32>
Chris (not verified)
on Oct 12, 2005
Wonder if anyone will even still read this but.. Having plenty of trouble using PSEXEC.. We began testing it with the MS Remote Desktop Connection software.. My command line is PSEXEC \\computer -u myacct -c -f G:\Directory\msrdpcli.exe The wierd thing, if on the remote machine Im logged in as myself (which has domain admin rights) the install of the RDP client works just fine. Logged on as any of our network users, I can see the process start and stop on the remote machine, but nothing ever gets installed. I dont get how this is supposed to help if I have to run to every remote machine and login. Ive also thrown in the -s flag, as well as the -e flag to no avail.. This morning we decided to test it again and roll out the Flash Player to a machine.. Now this time no matter who was logged in on the remote, PSEXEC just hangs there along with the Flash installer, and whatever wierd temp file we can see being created during it. I dont get it, am i just trying to install files that possibly because of where they go, dont work with PSEXEC?? I would think being the domain admin I should have free reign over it but nada..
santhosh.rao
on Nov 24, 2011
Hi All, I am using the following command PsExec.exe -u "username" -p "password" \\Remote_Server -w "F:\Test" cmd /c call test.bat The command executes successfully on the remote server by control does not seem to come back to the host system. If I check the task manager the task PsExec.exe is still running. is there a way i can stop the task once execution of the bat file execution is completed on remote system? Additional information: I am using this command in Informatica Command task
Anonymous User (not verified)
on Mar 4, 2005
I use psexec to run a batch file on the local machine as another user (which works without problems). However, after the batch has finished, psexec hangs for quite a long time until reporting that the process has finished. Is there anything one can do about that delay? Thanks in advance!
THOMAS (not verified)
on Apr 11, 2005
Your context looks incorrect. Can you reply with the full context you use to invoke stop_ob_portal_prd.bat?
Anonymous User (not verified)
on Feb 10, 2005
For those having problems getting the PSTools to run on the remote server due to security warnings/access denied/etc., here are a couple of tips, at least for Windows XP servers: - on the server turn off "simple file sharing" - create a user on the server with the same login name and password as the person who will be running psexec. - add that user to the Administrators group on the server Very important (!): - Now that you have changed the security on the server, open Computer Management and force all sessions from this user to close (logging off doesn't always do it). Now the server will see the user connect again and use the new security settings. - Steve Yates - Too err is human. To moo, bovine. ~ Taglines by Taglinator - www.srtware.com ~
Anonymous User (not verified)
on Apr 29, 2005
Hi Guys I need some help, Does anyone know what is used to separate the computer names in the text file when psexec is used with the @file parameter? I used psexec @test.txt -c “c:\test.exe” Contents of test.txt xxxpc001, xxxpc02, comma and space as separators doesn't work!!
Anonymous User (not verified)
on Jun 2, 2005
i'm not able to use the "net use" cmd with psexec, even as member of local Administrators group of the machine.
Caroline (not verified)
on Nov 13, 2008
See also this newer article by Mark Russinovich on PsExec: http://windowsitpro.com/article/articleid/95231/psexec-user-account-control-and-security-boundaries.html or type 95231 in the InstantDoc ID box at the top of this page. Plus, there's also http://windowsitpro.com/article/articleid/50102/let-users-install-software-without-giving-them-administrator-r ights.html or type 50102 into the InstantDoc ID box at the top of this page. Hope this helps!
Anonymous User (not verified)
on Aug 25, 2005
Try this...it will definately work...psexec \\sys_name net use.......for watching any network drive mapped..........if u want to map a drive.then use......psexec \\sys_name net use g: \\gstdfd\c$......Mohit
Paul (not verified)
on Jan 3, 2006
I want to run a perl job on a remote machin,I run "C:\>psexec \\sqlprd-clst1 c:\sqltest.pl" and get "PsExec could not start c:\sqltest.pl on sqlp The system cannot find the file specified." Any thoughts??
Anonymous User (not verified)
on Feb 25, 2005
Usually error code zero means no error occurred. Anything above zero is an error.
Anonymous User (not verified)
on Apr 7, 2005
To stop that file from running until you determine the source (Scheduler? or ??) get the following program - killbox - and end the process / file. http://www.bleepingcomputer.com/files/killbox.php
THOMAS (not verified)
on Jun 9, 2006
jmcpinto (at) gmail (dot) com, Check the version of psexec you are using. Are you running the jobs from different computers/servers with different versions of psexec? Using different versions has the tendency to create "connectivity" issues. Let me know! Thanks, Thomas Mshar ~ axomtechnology (dot) com
Anonymous User (not verified)
on Apr 19, 2005
I keep getting "Access is denied" message. Could somebody please assist me? I've gone through the other comments but I dont understand them. Please help. S.M. Adam
Anonymous User (not verified)
on Feb 2, 2005
Amazing tool!
THOMAS (not verified)
on Jun 9, 2006
JC Warren, run this command and it will return the requested IP information. psexec \\hostname -s "%windir%\system32\ipconfig" Thanks, Thomas Mshar www.axomtechnology.com
Anonymous User (not verified)
on May 20, 2005
alright.. a quick question im copying a .bat file through my network. the .bat file have this inside of it: NET USE P: \\apathtomynetwork Now, after the copy i m doing this : psexec /u myuser/p mypass \\%%Q \\%%Q\c$\startnet.bat %%Q beying my variable thats looking through a txt file thats = to the computer name in the list.. now on my local computer ( the one that im running all this script on ) im having the following: the command completed successfully \\%%Q(his name) \c$\startnet.bat exited on %%Q(his name) with error code 0. AND even thought it says completed , it still dont map the drive on the remote computer basicly. I know their is Active directory solutions but i do not want to use it for other reason.. is their a way to do that ? anybody know how to make that work ? if i execute the startnet.bat from a remote desktop on the %%Q computer , it works perfectly.. Please help!! thanks alot
tamir_sal (not verified)
on Nov 30, 2005
Hi all, well i'm wondering what is (and i quote) : "both the local and remote computers have file and print sharing (i.e., the Workstation and Server services) enabled". where can i set those shares and what do they mean ? Thanks T.
Miguel (not verified)
on Mar 24, 2006
QUIERO DESCARGAR ESTA UTILIDAD PARA SABER SI ME SIRVE O NO
Anonymous User (not verified)
on Mar 11, 2005
JC Warren I have the same problem here.. http://groups.google.de/groups?hl=de&lr=&selm=bitpi3%2416sf%241%40arachne.labyrinth.net.au looks like a solution here. :-)
Anonymous User (not verified)
on Apr 11, 2005
Hello, can anyone help me with this error, it appears from time to time on scheduled batch scripts but when i execute the script in command prompt manually it's allways ok. psexec \\rforsap33 c:\stop_ob_portal_prd.bat PsExec v1.56 - Execute processes remotely Copyright (C) 2001-2004 Mark Russinovich Sysinternals - www.sysinternals.com The process tried to write to a nonexistent pipe. Connecting to rforsap33... Starting PsExec service on rforsap33... Connecting with PsExec service on rforsap33... Starting c:\stop_ob_portal_prd.bat on rforsap33... c:\stop_ob_portal_prd.bat exited on rforsap33 with error code 1. Tnks, jmcpinto (at) gmail (dot) com
Asdaq (not verified)
on Aug 14, 2008
Good utility. But requires autocomplete(Tab) while using cmd. Can u tell me is there any way to autocomplete in psexec.
Eric (not verified)
on Sep 23, 2008
I’m trying to run psexec with an exe that contains this line of code: gfx.CopyFromScreen(0, 0, 0, 0, new Size(screenWidth, screenHeight), CopyPixelOperation.SourceCopy); It will hit an exception when run on a remote computer, but runs fine locally. This is the exception: Unhandled Exception: System.ComponentModel.Win32Exception: The handle is invalid at System.Drawing.Graphics.CopyFromScreen(Int32 sourceX, Int32 sourceY, Int32 destinationX, Int32 destinationY, Size blockRegionSize) at TakeScreenShot.Program.Main(String[] args) c:\browsershotsexes\TakeScreenShot.exe exited on TestVistaErtang with error code -532459699. Thanks, Eric PS This is all the code for the exe: using System; using System.Collections; using System.Text; using System.Drawing.Imaging; using System.Drawing; using System.Windows.Forms; using System.Runtime.InteropServices; namespace TakeScreenShot { class Program { #region Console Window property stuff [DllImport("kernel32.dll", ExactSpelling = true)] private static extern IntPtr GetConsoleWindow(); private static IntPtr ThisConsole = GetConsoleWindow(); [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)] private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow); private const int HIDE = 0; private const int MAXIMIZE = 3; private const int MINIMIZE = 6; private const int RESTORE = 9; #endregion static void Main(string[] args) { ShowWindow(ThisConsole, HIDE); //Hides Console Window Console.WriteLine("Minimizing the Current Console Window..."); System.Threading.Thread.Sleep(2000); Rectangle scrBounds = Screen.GetBounds(new Point(0, 0)); int screenWidth = scrBounds.Width; Console.WriteLine(screenWidth);
Anonymous User (not verified)
on Mar 10, 2005
The credentials supplied conflict with an existing set of credentials.can anyone please solve this problem
Murdoch07 (not verified)
on Oct 31, 2008
Trying to run an install .exe on a remote PC. How can this be done in passive mode, so that all default options are used and the program installs? So far, I can only get the Welcome Page for the install program to appear. Thanks.
rajeev (not verified)
on Sep 19, 2006
Hi, I got a problem while executing certain exe files like notepad.exe and another exe which perform execution of another exe (which changes position of cursor on screen). When I execute this file using psexec either on remote or local PC there seems to be no effect even though the console gives message executing the exe ..(seems to get hanged). These exe file run if I call them manually or on command prompt but does not seem to work with psexec even with full path of exe given..any ideas?

Please or Register to post comments.

IT/Dev Connections

Las Vegas
September 30th - October 4th

Paul ThurottYou'll have the opportunity to experience:
• The Microsoft
Technology Roadmap
• Office 365 Implementation
• Hyper-V Optimizing
• Windows 8 Deployment
and much more!

Come See Paul Thurrott & Rod Trent in Person!

Early Registration Now Open

Upcoming Training

Mastering System Center 2012

During over 6 hours of training you can join John Savill from your computer as he will walk you through the key components and capabilities of System Center 2012, what’s involved in using the components, and the benefit they can bring to your environment.

Register Now

Current Issue

May 2013 - The NameTranslate object is useful when you need to translate Active Directory object names between different formats, but it's awkward to use from PowerShell. Here's a PowerShell script that eliminates the awkwardness.

CURRENT ISSUE / ARCHIVE / SUBSCRIBE

Windows Forums

Get answers to questions, share tips, and engage with the Windows Community in our Forums.