marioval Posted December 11, 2008 Report Share Posted December 11, 2008 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 offpsexec \\computername -u username -p password defrag.exe c: -f@pauseThe 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 Quote Link to comment Share on other sites More sharing options...
ɹəuəllıʍ ʇɐb Posted December 12, 2008 Report Share Posted December 12, 2008 You could pass the computer name as a parameter when you execute the batch script, then use that argument in your program callpsexec \\%1 -u username -p password defrag.exe c: -fI have never used it myself, but that's the syntax, according to http://www.robvanderwoude.com/parameters.html Quote Link to comment Share on other sites More sharing options...
Luis 2012 Posted December 12, 2008 Report Share Posted December 12, 2008 @echo offecho "Enter Computer Name"set /p computername=psexec \\%computername% -u username -p password defrag.exe c: -f@pauseI'm not very good with the command promt, but that should work. Quote Link to comment Share on other sites More sharing options...
ɹəuəllıʍ ʇɐb Posted December 12, 2008 Report Share Posted December 12, 2008 @echo offecho "Enter Computer Name"set /p computername=psexec \\%computername% -u username -p password defrag.exe c: -f@pauseI'm not very good with the command promt, but that should work.That will insert the local computer name, not any remote one. Quote Link to comment Share on other sites More sharing options...
ɹəuəllıʍ ʇɐb Posted December 12, 2008 Report Share Posted December 12, 2008 You could pass the computer name as a parameter when you execute the batch script, then use that argument in your program callpsexec \\%1 -u username -p password defrag.exe c: -fI have just tested it - it works. Quote Link to comment Share on other sites More sharing options...
Slyke Posted December 12, 2008 Report Share Posted December 12, 2008 Would be easier Pat's way, since you could use another batch file (Or a list of them) to call the defragging one. Quote Link to comment Share on other sites More sharing options...
ɹəuəllıʍ ʇɐb Posted December 12, 2008 Report Share Posted December 12, 2008 He will need only one batch script, e.g. def.bat, then execute it with the machine name as parameter:def.bat machine1def.bat machine2...etc. Quote Link to comment Share on other sites More sharing options...
Chris Posted December 16, 2008 Report Share Posted December 16, 2008 @echo offecho "Enter Computer Name"set /p computername=psexec \\%computername% -u username -p password defrag.exe c: -f@pauseI'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. Quote Link to comment Share on other sites More sharing options...
kentark Posted February 11, 2009 Report Share Posted February 11, 2009 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 offpsexec \\computername -u username -p password defrag.exe c: -f@pauseThe 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. ThanksWhy 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.