I was hoping I could have some help with this. I have about 300 computers that I have to clear all the temporary internet folders on and separately do a logoff on them.
Currently I have a file located on the C: drive that has the following command:
Clear temporary internet folders:
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255
log off
shutdown /l /t 0 /f
Here is the PSexec command I use to remotely execute that command on every computer:
#echo off
psexec #C:\_\complist.txt -u Admin -p PASSWORD -i. c:\clearcache.cmd
The problem I am having is that it is taking really long, about 30 - 35 minutes because it does one at a time. Is there anyway I can speed this up? Maybe instead of doing 1 at a time I can do all at once?
If anyone can help improve the speed or help me find a better way I would be so grateful.
Thanks
Error I am getting when executing:
the other way round: instead of doing all at once, do them separately. Sounds contraproductive? Parse complist.txt with batch and start psexec for each single computer instead of a list of computers:
for /f "delims=" %%i in (C:\_\complist.txt) do (
start "%%i" psexec \\%%i -u Admin -p PASSWORD -i. c:\clearcache.cmd
)
start creates a new process for executing psexec on every single computer and doesn't wait for it to finish, so they all run (nearly) parallel.
You could look at SCCM to run a script like this, lot of overhead if its not in place yet. But could be worth looking at for larger deployments in the future.
I have used PDQ Deploy in the past works well, they have a few levels of licensing including a free one depending on your business. DPQ Modes
Also have you considered pushing out a scheduled task that clears the IE favorites on a set date, this could also run the log off command but that could get messy. With a scheduled task in place could just run the log off command like you have in the past which wont be waiting for the clean command to finish.
If you have a domain you can use Group Policy to push out the scheduled task to the PCs saving you from making a import script and deploying that with psexec.exe.
Just a few Ideas for you.
Related
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.
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
First i would just like to point out, i know very little about this subject matter. Okay, now that that is out of the way.
I am trying to setup a batch script to ssh to a list of IP's (about 50) and create a simple cron job to reboot the box it connects to every 24 hours at midnight local time.
I already create the cron job in VI, but i have no idea how to make this batch script work. I have tried to piece meal a batch together but, have had zero luck. Lastly i think i should mention that i am making the batch file on a windows box, and sshing to a Linux shell. If their is anything you guys need let me know and i will try to supply it.
Thanks in advance!
Edit: for clarity
May this be useful?
HERE
Inside the "commands.txt used in the script i linked to:
shutdown -r -t sec 0 Rebooting
exit
I'm making a Cloud Drive program for my university (like dropbox for example, but much simpler), which let users automatically upload files on a server and share them with other users
I wanted to make an option, so that if someone boots the machine, the process will start automatically
What I think I have to do is to add an entry in the register at the key: HKEY_LOCAL_MACHINE/sofware/Windows/CurrentVersion/Run and I wrote these lines of code:
system("REG ADD HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Run /v uCloud.exe /t REG_SZ /d \"C:\\Desktop\\uCloud\\uCloud.exe\" /f");
I also tried with the functions: RegOpenKeyEx and RegSetValueEx
the problem is that in both the cases I need administrator rights
If I edit the HKEY_CURRENT_USER the program automatically starts on boot, but it doesn't work at all (I mean I see the process, but it does nothing. I have to close the process and open it again manually and then it starts to download and update the stuffs)
Thanks a lot
When you use the task scheduler, you can use admin rights; see here: http://www.techrepublic.com/blog/window-on-windows/make-vista-launch-uac-restricted-programs-at-startup-with-task-scheduler/616
I have a web application, that sometimes hangs. I want to investigate the reason, and I need to get a memory dump of the process, when it hangs.
So my idea is to monitor the website, when I am detecting the hang, I want to start a .bat script which captures the memory dump, then runs IISRESET in order to restart so that the site will start responding again.
My problem is, that adplus starts another process (cdb.exe) and returns immediately. I need to wait for cdb.exe to finish, before I can run IISRESET. Is there any way to do that in a batch script ? Or, can I specify on the adplus command line, that it should not return until the memory dump has been collected ?
Regarding the second part of your question, the answer is yes: you can both (1)specify the wait on the commmand line (as long as you can access to and modify it); and (2)wait for a process to finish in a batch file.
In their simplest form, do
(1) use START /WAIT cdb parms instead of just cdb parms
(2) try FOR /F "tokens=1,2" %a in ('TASKLIST ^| FIND /I "cdb.exe"') DO #ECHO %a %b and substitute ECHO for the command you want.
To create the memory dump of your web application, the Microsoft Debug Diagnostic Tools are your best option.
You can create an "IIS Hang" rule, monitoring a specific URL, and creating a memory dump whenever no response is received within a specified number of seconds.
The Debug Diagnostics Tools will not help you with regard to restarting IIS (or your app pool), but in general the built-in Application Pool restart options should be sufficient for that. If you make sure "Enable Pinging" is set for your AppPool (on its Health tab), and you also set the other Health/Recycling parameters appropriately, your app should continue responding no matter what happens.
If not, monitoring the output folder with crash dumps from your "IIS Hang" DebugDiag rule, and restarting IIS whenever new files appear should definitely do the trick...