PsExec Option 开关 -s 的妙用

 发现PsExec Option 开关 -s 的2个妙用。

-s的含义是:用System账号运行。

 

1。

我遇到过下面一个怪问题,尝试解决了好久,都失败了!

 

I encounter a problem will PSExec.

I notice that if I use PsExec to execute any command from current local computer and meanwhile Psexec uses @file option to fetch the computer name, it doesn't work.
 
For.e.g.
There is an computer name devccaapp01,   in its c:\deleteLogs folder, there are 2 files.
One is Psexec.exe ( v1.98). The other is the text file: serverlist-app.txt, I input the local computer name devccaapp01 in it.
 
Then, I run following command on the computer devccaapp01.
 
C:\deleteLogs>
C:\deleteLogs> psexec @serverlist-app.txt forfiles /P C:\ccanywhere\log /M *.log
/C "CMD /C ECHO @FILE"
PsExec v1.98 - Execute processes remotely
Copyright (C) 2001-2010 Mark Russinovich
Sysinternals - www.sysinternals.com
\\devccaapp01:
PsExec could not start forfiles on devccaapp01:
The parameter is incorrect.
C:\deleteLogs>
 
Psexec returned error.
PsExec could not start forfiles on devccaapp01:
The parameter is incorrect.
 
 
 
But, if I run following command on the same computer, it works.

C:\deleteLogs> psexec \\devccaapp01 forfiles /P C:\ccanywhere\log /M *.log /C "CM
D /C ECHO @FILE"
PsExec v1.98 - Execute processes remotely
Copyright (C) 2001-2010 Mark Russinovich
Sysinternals - www.sysinternals.com
forfiles exited with error code 0.
 
 
Also, if I input any other remote server name in the text fileserverlist-app.txt, for e.g. devccaapp02
Then, I run following command, it works too.
 
C:\deleteLogs> psexec @serverlist-app.txt forfiles /P C:\ccanywhere\log /M *.log
/C "CMD /C ECHO @FILE"
PsExec v1.98 - Execute processes remotely
Copyright (C) 2001-2010 Mark Russinovich
Sysinternals - www.sysinternals.com
\\devccaapp02:

"ACDServer_55_20110817_095258_1072.log"
...
"tcpipbus_1384_20110816_201322_1384.log"
"tcpipbus_1384_20110816_201322_1384_1.log"
forfiles exited on devccaapp02 with error code 0.
C:\deleteLogs>

 

最后,我用-s解决了!用System账号运行。

C:\deleteLogs>psexec @serverlist-app.txt -s forfiles /P C:\ccanywhere\log /M *.log
/C "CMD /C ECHO @FILE"

 

 

2.

 

有时,你如果运行一个长时间的任务,如果你是使用当前登陆账号运行的话,当你log-off windows的时候,所有的这些以当前登陆账号运行在进程里的程序都会被干掉,包括用psexec运行的程序!!!

这个时候,你就必须要用 -s 来解决!

你可能感兴趣的:(command,cmd,system,file,input,2010,Windows及软件故障排除,实用工具介绍,操作系统,Windows使用小技巧)