Jump to content

Defraggin a remote machine


Recommended Posts

I currently use the command line with psexec to remotely defrag machines on my network. I have a simple batch file that includes the following syntax:

@echo off

psexec \\computername -u username -p password defrag.exe c: -f

@pause

The username and password is always the same but the computer name is not. So each time I run it I have to edit the syntax, change the comp name, save it, then run it. is there a way I can have it prompt me for a computername when I double click it instead? Perhaps a VB script which I have no experience with. Thanks

Link to comment
Share on other sites

You could pass the computer name as a parameter when you execute the batch script, then use that argument in your program call

psexec \\%1 -u username -p password defrag.exe c: -f

I have never used it myself, but that's the syntax, according to http://www.robvanderwoude.com/parameters.html

Link to comment
Share on other sites

@echo off

echo "Enter Computer Name"

set /p computername=

psexec \\%computername% -u username -p password defrag.exe c: -f

@pause

I'm not very good with the command promt, but that should work.

That will insert the local computer name, not any remote one.

Link to comment
Share on other sites

@echo off

echo "Enter Computer Name"

set /p computername=

psexec \\%computername% -u username -p password defrag.exe c: -f

@pause

I'm not very good with the command promt, but that should work.

That will insert the local computer name, not any remote one.

It will use whatever you set it to.

But %COMPUTERNAME% is already taken - just use a different name.

Link to comment
Share on other sites

  • 1 month later...
I currently use the command line with psexec to remotely defrag machines on my network. I have a simple batch file that includes the following syntax:

@echo off

psexec \\computername -u username -p password defrag.exe c: -f

@pause

The username and password is always the same but the computer name is not. So each time I run it I have to edit the syntax, change the comp name, save it, then run it. is there a way I can have it prompt me for a computername when I double click it instead? Perhaps a VB script which I have no experience with. Thanks

Why not RDP into the server via admin and run the defrag? I would recommend using an alternative defrag to the one windows provides. Is this a managed server or local machine? If it is a manged server call up the techs and have them defrag for you. I have one hosted with Server Intellect and have them set a schedule for defrag, updates, and malware scans. Makes like much easier, less time, and can work on issues that are more time consuming.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy