...and by %computername%, I of course mean whatever variable you'd like to 
expand.

From: Crawford, Scott [mailto:crawfo...@evangel.edu]
Sent: Monday, November 08, 2010 5:34 PM
To: NT System Admin Issues
Subject: RE: PSEXEC and %homedrive%

Your entire command line gets parsed on your computer first and then it 
performs the operation.

Assume you're running from a PC named Workstation against a server named Server.

Psexec \\server<file:///\\server> cmd /c echo %computername%

Gets parsed to

Psexec \\server<file:///\\server> cmd /c echo Workstation

Which is exactly what the server does.

What you want is

Psexec \\server<file:///\\server> cmd /c echo ^%computername^%

The carets escape the percents to pass the command echo %computername% to the 
server.

From: Christopher Bodnar [mailto:christopher_bod...@glic.com]
Sent: Monday, November 08, 2010 5:26 PM
To: NT System Admin Issues
Subject: RE: PSEXEC and %homedrive%

Thanks Carl,

I see what you are saying now. I just don't understand the behavior. I would 
think anything after the "SERVERNAME" would be evaluated on the remote machine, 
but that doesn't' seem to be the case when specifying a variable.

thanks


Chris Bodnar, MCSE
Systems Engineer
Distributed Systems Service Delivery - Intel Services
Guardian Life Insurance Company of America
Email: christopher_bod...@glic.com
Phone: 610-807-6459
Fax: 610-807-6003



From:        "Carl Houseman" <c.house...@gmail.com>
To:        "NT System Admin Issues" <ntsysadmin@lyris.sunbelt-software.com>
Date:        11/08/2010 06:10 PM
Subject:        RE: PSEXEC and %homedrive%
________________________________



Do this

psexec \\SERVERNAME<file:///\\SERVERNAME\> cmd /c set

So what's the difference.  Look again at this very carefully...

psexec \\SERVERNAME cmd.exe /c echo %homedrive%

Hint:  On what computer is %homedrive% expanded ?

Carl

From: Christopher Bodnar [mailto:christopher_bod...@glic.com]
Sent: Monday, November 08, 2010 5:16 PM
To: NT System Admin Issues
Subject: Re: PSEXEC and %homedrive%

I would agree with this, except that when I enumerate that using PSEXEC, I get 
the correct value,  so it does seem to be setting it:

***************************************************************************************
H:\Utilities>psexec \\SERVERNAME cmd.exe /c echo %homedrive%

PsExec v1.94 - Execute processes remotely
Copyright (C) 2001-2008 Mark Russinovich
Sysinternals - www.sysinternals.com


C:
cmd.exe exited on gbtinvsql2x with error code 0.
***************************************************************************************


Chris Bodnar, MCSE
Systems Engineer
Distributed Systems Service Delivery - Intel Services
Guardian Life Insurance Company of America
Email: christopher_bod...@glic.com
Phone: 610-807-6459
Fax: 610-807-6003



From:        Ben Scott <mailvor...@gmail.com>
To:        "NT System Admin Issues" <ntsysadmin@lyris.sunbelt-software.com>
Date:        11/08/2010 04:15 PM
Subject:        Re: PSEXEC and %homedrive%

________________________________




On Mon, Nov 8, 2010 at 1:45 PM, Christopher Bodnar
<christopher_bod...@glic.com> wrote:
> I've got a VBS script that we use pretty frequently, and I was trying to run
> it remotely using PSEXEC against a bunch of systems. Finally narrowed the
> problem down to the fact that for some reason, the %HOMEDRIVE% variable and
> PSEXEC didn't mix well on some systems.

%HOMEDRIVE% is set as part of the user logon process, which, in my
experience, generally doesn't happen for anything except a typical GUI
logon.

(%HOMEDRIVE% and %HOMEPATH% both come from the setting on the
"Profile" tab of an account's properties.)

-- Ben



~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to 
listmana...@lyris.sunbeltsoftware.com<mailto:listmana...@lyris.sunbeltsoftware.com>
with the body: unsubscribe ntsysadmin

~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to 
listmana...@lyris.sunbeltsoftware.com<mailto:listmana...@lyris.sunbeltsoftware.com>
with the body: unsubscribe ntsysadmin

~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to 
listmana...@lyris.sunbeltsoftware.com<mailto:listmana...@lyris.sunbeltsoftware.com>
with the body: unsubscribe ntsysadmin

~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to listmana...@lyris.sunbeltsoftware.com
with the body: unsubscribe ntsysadmin

Reply via email to