Page 1 of 1 1
Topic Options
#198714 - 2010-05-25 10:21 PM psexec and Shell and/or Run
Georges_K Offline
Getting the hang of it

Registered: 2005-02-17
Posts: 83
Loc: Chino, CA
Hello all,

I have spent more than 2 hours trying to figure out this problem, and I think it's time to run it by you ! \:\)

I have always been able to run psexec to trigger a kix script on a remote machine without any problems.

Today, as I was writing some scripts, I used that same method, only to find that it's always failing. I'm running XP SP3 in a VMWare View 4 environment.
Running kix32 version 4.61 (also tried 4.60)
psexec is at version 1.96
logged on user currently has local admin privileges, though I'd prefer for the particular script I'm working on to run in the system account without loading a profile, as non of what it's doing is profile related. (changing some files in the root of C: and making a couple of registry entry changes in HKLM)

Here's the situation, (and this is just to illustrate):

Kix Code: (test.kix)
 Code:
BREAK on
If Exist("C:\test.bat")
 ? "C:\test.bat found"
Else 
 ? "C:\Test.bat not found"
EndIf

Run '%COMSPEC% c:\test.bat'
? "DEBUG: " + @ERROR + " - " + @SERROR
get $x


If I run this on the workstation itself: kix32.exe c:\test.kix.
I get the correct result, and test.bat is executed.

However, I run this same script through psexec:
psexec -i \\<workstation> -u <username> -p <password> c:\windows\system32\kix32.exe c:\test.kix

I get the following:
C:\Test.bat found
DEBUG: 2 - The system cannot find the file specified.

This has always worked, until now... I have tried removing the username and password, and running psexec with the -e argument to not load current user profile. Nothing worked. The user on the workstation is a local admin, so I know they have read access to the file.

Also, I found one thing that was curious in the Application Log:
Event Type: Error
Event Source: KIXTART
Event Category: None
Event ID: 1312
Date: 5/25/2010
Time: 1:14:01 PM
User: N/A
Computer: AERIESCS-SB-001
Description:
The description for Event ID ( 1312 ) in Source ( KIXTART ) cannot be found. The local computer may not have the necessary registry information or message DLL files to display messages from a remote computer. You may be able to use the /AUXSOURCE= flag to retrieve this description; see Help and Support for details. The following information is part of the event: WkstaUserGetInfo failed Error : A specified logon session does not exist. It may already have been terminated. (0x520/1312).

Would anyone have any pointers as to what to look for at this point? I'm pretty stumped.

Thanks for any assistance you may be able to provide!

_________________________
Network Specialist
Chino Unified School District

Top
#198717 - 2010-05-26 05:25 AM Re: psexec and Shell and/or Run [Re: Georges_K]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4574
Loc: USA
It's been a long while since my days with psexec... but looking through an old script I used(and ick did I have some bad coding habits back then), it appears the remote path needs to be a unc path not a local path.

I cobbled this code together from my script, and it is untested, but should show you enough of what I was doing.

 Code:
$remotesystemroot=readvalue("\\" + $remotepc + "\hkey_local_machine\software\microsoft\windows nt\currentversion\","systemroot")
$remotesystemroot=right($remotesystemroot,len($remotesystemroot)-3)
$remotedestdir="\\" + $remotepc + "\" + c$ +"\" + $remotesystemroot + "\system32"
shell $vncdir + "\psexec.exe" "\\" + $remotepc + " -i wscript " +  $remotedestdir + "\yesno.vbs"
_________________________
(... better days ahead)

Top
#198721 - 2010-05-26 09:44 AM Re: psexec and Shell and/or Run [Re: Allen]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
The error almost certainly relates to not finding CMD.EXE

Consider wrapping %COMSPEC% in quotes to preserve the path.

Also, when executing KiXtart in a new environment it's usually a good idea to fix the current working directory:

 Code:
BREAK on
; Fix current working directory
GO C:
CD \
If Exist("C:\test.bat")
 "C:\test.bat found"+@CRLF
Else 
 "C:\Test.bat not found"+@CRLF
EndIf

; Wrap %COMSPEC% in quotes to preserve the path - especially useful if it contains spaces.
Run '"'+%COMSPEC%+'" c:\test.bat'
"DEBUG: " + @ERROR + " - " + @SERROR+@CRLF
get $x

Top
#198726 - 2010-05-26 05:16 PM Re: psexec and Shell and/or Run [Re: Richard H.]
Georges_K Offline
Getting the hang of it

Registered: 2005-02-17
Posts: 83
Loc: Chino, CA
Thank you guys for your responses.
Allen, I actually have never tried method in opening the file in question via UNC, but I do know for a fact that I can call a local file on the remote PC.
i.e: psexec -i \\remoteserver c:\windows\system32\notepad.exe c:\test.txt

In the above scenario, test.txt is actually created on the c:\ drive of the remote server. I wonder if back then (in older version), psexec had different behavior (??)

Richard,
Thanks for your pointer regarding wrapping %COMSPEC% in quotes.

Fortunately for me, since I'm working in VMWare, I was able to go back to a previous snapshot of the workstation, and get psexec to work. So, perhaps there were some changes that I had made in the latest release that broke the psexec functionality. Bottom line, I'm working again, but I really wish I could've known what the problem was, in order to avoid it in the future.

Oh well, in any case, I think I'm good. Thanks again for your time! I really appreciate it!
_________________________
Network Specialist
Chino Unified School District

Top
#198768 - 2010-06-03 12:45 AM Re: psexec and Shell and/or Run [Re: Georges_K]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
Previous snapshot? Off topic, but how long are you keeping your snapshots in VM? More than a few days can be dangerous to the VM environment!

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#198769 - 2010-06-03 09:35 AM Re: psexec and Shell and/or Run [Re: Glenn Barnas]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
 Originally Posted By: Glenn Barnas
Previous snapshot? Off topic, but how long are you keeping your snapshots in VM? More than a few days can be dangerous to the VM environment!


What's the issue? From what I know about the VM snapshot process it's a pretty ugly way to achieve it, but other than inefficiency and the overhead of folding the deltas back in when the snapshot is deleted I hadn't spotted anything inherently dangerous.

I'm going to start a large scale deployments of VMware over the next 12 months and if there is a property of snapshots that affect the design and implementation now is a good time to know it.

Top
#198794 - 2010-06-07 11:16 PM Re: psexec and Shell and/or Run [Re: Richard H.]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
A buddy of mine made a snapshot at a client of his. He never deleted or applied the snapshot. The snapshot file grew until it (nearly) filled the disk volume. The server was down for 2 days, and he could not resolve the problem without getting VM support involved and adding storage to the system.

Per the VM engineer, snapshots are intended to provide a facility to roll back after applying updates or making significant changes. If the update/change works, apply the snapshot. If it doesn't, roll back. A few days is OK, maybe even a week, but it's not intended to be used for months on end..

Here's some background.. you create a guest with a 40G drive. You create a snapshot - the 40G is "frozen" and the deltas are written to the snapshot file. This file grows with each file change, while the base disk remains unchanged. Imagine this on a file server - after a few weeks the snapshot file can easily exceed the size of the original disk.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1013 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.057 seconds in which 0.026 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org