PSEXEC Crashing PC - batch-file

I have been using psexec successfully for a couple of years now. Recently, I have had some major issues when running on several remote machines. Calling psexec from a simple batch file seems to completely crash (restart) the computer, leaving the bewildered pc locked on the DELL startup screen (same issue on 3 separate computers).
Anyone having a similar issue? This seems to occur when using the old and new version of psexec (May 2014 release v2.11). Could this be a windows update issue (Windows 7 64bit)?
FYI, here's the process I call from a .bat file (run_model.cmd contains local exe).. note: This opens up in a loop, so that I get a new window for each model run.
start cmd.exe /c psexec -i -s \\VOSTRO460-4 \\VOSTRO460-4\model\run_model.cmd
If not, can anyone suggest an alternative to psexec which works as simply as this?
Cheers
Neil

Related

Running an exe on multiple pcs on sync

I'm trying to run an exe on multiple pcs on sync.
Im using psexec, this is what I have till now:
I have a batch file with this:
start psexec \\pc01 -i -s -d c:\videos360\video360.exe
start psexec \\pc02 -i -s -d c:\videos360\video360.exe
With this I can start the exe in the 2 pcs, but never totally on sync.
Anyone has some idea of how can I make them run more on sync?
Thanks in advance.
Sorry for my bad English...
First sync the clocks on both machines. You can run a script on one of them to sync to the other or have them both sync to a central time source. Then add a task to Task Scheduler on each machine to start the application at the same time. That's about as close as you're going to get without resorting to some sort of IPC mechanism between the processes (requires source code access to video360.exe).
See
schtasks.exe
Windows time service tools
You won't need psexec because schtask can be used to manage tasks on the remote machines. It would be up to your script to change the next time to fire the task, or you could setup a repetitive task that fires every minute or two and just enable/disable the task. I believe there's a one-shot option as well.

.bat to stop windows Update

I have gotten tired of searching how to stop Windows Updates from running permanently in Windows 10 since every after a restart it runs again. It came to my mind that maybe I could make a .bat file that could stop the windows update in the services so that I could just click it every time I turn on my laptop.
I have known of the sc start/stop serviceName. My question is, what is the name of the Windows Update service? Because when I type in windows update in in the serviceName, it would show that the service is not installed.
simple batch which you can even put into your Run at start up. This one works on Windows 8 and older should perhaps work on Windows 10 as well.
#echo off
net stop "Windows Update"
You can also stop it together with the background downloading processes.
This one works on windows 10
#echo off
net stop wuauserv
net stop bits
net stop dosvc
The name of your service is wuauserv.
If you want to get a list of display names with their associated service names you can do so relatively quickly by utilising WMIC at your Command prompt.
WMIC /Output:Services.txt Service Get DisplayName,Name&&Services.txt
The Services.txt file will be located in the Command prompt's current directory.
The powershell commands to :-
Stop Windows update is:
Stop-Service wuauserv (Run as admin)
Start Windows update is:
Start-Service wuauserv
Unplug the LAN wire or disconnect your system from the internet as soon as possible. Write "Services.msc" in a run (Windows key + R), then scroll down and search Windows update option there. Double click on that, select the startup type "disabled" then click ok, it will stop the windows update and also fix blue screen problems during upgrade on Windows 10.

Psexec Error Code -2146232576

I'm trying to open up a an .exe program that is on a remote computer through my main desktop using a batch file and psexec.exe.
I have been able to remotely kill programs using pskill, but when I run the command line required to open a program the window opens up for a fraction of a second before closing down due to an error. The error code it gives is: -2146232576.
I've tried Googling what this error actually is but I can't find much. Does anyone know for sure what this error relates to?
This is the batch file I made that does not work:
cd c:\Users\[local user]\Downloads\PSTools\
psexec.exe \\computername -u [user] -p [password] "C:\Users\[user]\Desktop\SQAUtilities\utlity.exe"
Note: I found a question on StackOverflow which is similar, but has a different error code:
psexec error code -1073740771
And also:
Error code 1073741502 when running psexec through TeamCity
This one has an answer that says the error is "a low-level .NET initialization error, the CLR cannot get loaded":
visual studio 2010: error code -2146232576 (0x80131700)
This is likely the exit code of utility.exe that PSExec is passing back to you, not an error generated by PSExec.
Here's one possible source:
FIX: 0x80131700 error code when starting or configuring the Enterprise Single Sign-On Service
I don't know what utility.exe does, but if it attempts to perform Windows authentication, PSExec might be blocking it. In my experience, PSExec deliberately blocks some actions (under certain circumstances). For example, if you don't use a username/password, all attempts to access remote shares fails instantly.
Since you're providing some creds, this might not be the precise problem, but if utility.exe requires access to your Kerberos tickets or something, they might not be accessible in a PSExec session.
Things to Try
Do you know that this command (utility.exe) works on the remote machines as your user when run interactively (GUI logon)? Surely you've already tried that, but just to make sure...
Is the build directory on the remote computer or is it a share on a third machine? The method of accessing those files might require more steps within PSExec (like mapping a drive, etc.).
If the program absolutely requires a GUI, you may have to allow it to interact with a specific GUI session using the -i parameter of PSExec. You might try logging into the remote machine, running the command with -i 2 (or whatever session qwinsta tells you you're using—2 is common for remote desktop connections) and see if it opens any error dialogs that are more informative.
You might try running ProcMon on the remote machine while you run the PSExec command and seeing if there are any ACCESS_DENIED or other failures that it notices.
Got the same error while remotely running an EXE install file (not copying it local). As near as I can tell this is an error related to insufficient permissions. For me, the simple addition of the -S switch (to run as SYSTEM) fixed my problem.
Why this works I'm not sure - I'd always thought SYSTEM was strictly limited to local resources, yet the EXE I'm running is located on a network share.
Hope this helps someone.
I got the same error lately and found out why I get this.
You must make a local copy of "utility.exe" on the remote computer for before launching it via PsExec.
for /f "usebackq delims=" %%i in ("d:\utility\remote_computers.txt") do (
xcopy "D:\utility\utility.exe" "\\%%i\d$\" && psexec \\%%i -u %%i\administrator -p password cmd /c "/i \\%%i\d$\utility.exe"
)
Pause

Batch file doesnt run after deploying from SCCM

I have a batch file which uses gpresult /v and saves the output in a text file and copy that text file to a shared folder. This batch when i run on my local machine works perfectly fine but once i deploy it through SCCM it says can not open file with error code 4. I dont know what is wrong in the file.
the code is Like this:
#echo off
gpresult /v >%computername%.txt
xcopy %computername%.txt \some path
Error 4 is "The system cannot open the file.", as if the path is invalid or the open() fails for some other reason.
Do you know what directory the program is running in (CWD)?
That's where the results of gpresult are going (if the output redirection succeeds).
gpresult is not going to produce meaningful user-level data for the SYSTEM user.
Perhaps you should use gpresult /v scope computer.
Why are you using xcopy when you're only copying one file? xcopy really only has added value (over copy) if you are copying directories.
xcopy's behavior changes depending on how you specify the target. If the target ends with the directory separator (backslash), xcopy treats it like it's a directory. If it doesn't and the target doesn't exist, xcopy asks you what to do, which causes automated processes to pause indefinitely waiting for user input.
SCCM Programs Run as 'NT Authority\SYSTEM'
When SCCM (2007) runs a program, the program doesn't run as a regular user. It runs as the highest privilege user (sort of), SYSTEM.
This account is not a regular account, and many settings and environment variables that exist and are predictable for a regular user are different or do not exist for SYSTEM.
One particularly frustrating "feature" of the SYSTEM account's profile is that it is nestled away under %WINDIR%\System32, and so it is subject to filesystem redirection whenever you refer to anything relative to the profile.
Try this: use psexec -s (sysinternals) to get shell access as the SYSTEM account and run the command in that environment to see how it behaves. This is as close as we can get to an environment like the one SCCM programs run under.
When SCCM runs the command, the CWD will probably be somewhere under %WINDIR%\SysWOW64\CCM\ and may be invoked with the 32-bit version of CMD.EXE.
I have a question in regards to something similar to this. So I have an uninstall bat that runs. Due to the vendors uninstall it causes a force close of the windows explorer UI. So in haste to solve that issue I added a call to open explorer.exe. There is a problem with this as someone pointed out to me. Actually as soon as he said I knew exactly what he was saying and where he was going with his statement. Calling explorer.exe would be fine except that the bat is running under the system context not the user so when explorer is restarted it will start under the guise of the system desktop profile not the user's. I know there is way to still run under the guise of system but to restart explorer under the currently logged in user's profile.

Winzip hanging up in scheduled task batch file

I have a simple batch file as seen below that should extract a zip file to the root of E:. The zip file is valid and I can run the batch file from the command line just fine.
Instead of completing the task, it continues to inform me that the Status is "Running". The problem is, it is not running and the file never gets unzipped.
The task is running as a Domain Admin that has been specifically added as an Admin on the box.
Are there any known problems with using zip files in Scheduled Tasks. I actually have this same problem on 3 out of the 12 boxes this task runs on, but there is no rhyme nor reason as to why some servers work, and others don't.
Any ideas on how to debug what is going on, or a solution would be very helpful.
Here is the batch file I'm attempting to run.
SET RootPath=E:
SET WinzipLocation=E:\Program Files\WinZip
"%WinzipLocation%\winzip32" -e -o %CD%\TestZipFile.zip %RootPath%
Try to use the WinZip Command Line Support Add-on.
what if you use 7-zip in command line?
I realized after posting that the "bad" servers were all 64-bit. I was running the 32-bit version of winzip. Since the company I work for doesn't see the benefit in purchasing any software, I had no other option but to starting using 7-zip. I have not tested for any performance increases or hits, but I do not that it works, regardless of the environment.
Thanks for the answers, but it looks like without the 64-bit version of winzip....i have no other options.

Resources