Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Run Maintenance on a PC through Script.

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,37156
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Run Maintenance on a PC through Script.
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1] 2   next >   >>
Login
Message << Older Topic   Newer Topic >>
 Run Maintenance on a PC through Script. - 8/21/2006 8:55:15 PM   
  morpheus83uk

 

Posts: 373
Score: 0
Joined: 8/21/2006
Status: offline
Hello,
Is there a way where by we can run a script to do the following (With Admin Account Details):

Restart the PC before the procedure so nothing is running which could stop or interfere with the procedure

Remove All "Account Unkown" profiles and accounts off the local PC

Remove All Accounts which have not been Accessed / Modifieed on the local PC for say the last 2 Months

Remove Unused Applications (Such As Netscape Navigator 4.7 and remove the remaining folders afterwards)

Clean out Tempory Files (Internet Temp, Historys, Stored Passwords, Temp Folder etc)

Run Dick Cleanup on Each Drive and Remove Everything

Clear the system restore files apart from the most recent

Clean the Registry with Regseeker (Free Softtware Off the net Very good too!!) until it cant find any problms there

Virus Scan the PC

Defragment The PC each Drive in turn (I have a script for this already found on the net but does not complete fully what I want when I get home I will post it here)

Report Any errors to an E-Mail Address with machine name and error information

Then Restart the PC log in as admin and then shut down.

I have been tasked with this as were seeing if we can impliment this to out PC's for them to run more efficiently I mean I was thinking of a script or batch file maybe which we could load into group policy for the PC's to run a maintenance wizard on this file.

When it comes to the time pop up a message on the PC which says please DONT switch your PC off as scheduled maintenance will be taking place at 8PM tonight and then when they shut down it just logs them off or something with yet another notification saying the same thing.

To be honest I have no idea on how I would even attemp this so any suggestions would be greatly appreciated!!!

Or

Does anyone know if there is any software out there that can automate a process. Like if you were to record a macro in Word or Excel say you do what you want and then when finished click the macro which will excicute teh commands you have done, and it builds the code in the background.

Does anyone know if there is any software out there which will create VBS Scripts as an output file but creates the file in the same mannor as Word Or Excel's macros's do?

Many Thanks

James
 
 
Post #: 1
 
 RE: Run Maintenance on a PC through Script. - 8/22/2006 12:16:47 AM   
  ebgreen


Posts: 4970
Score: 31
Joined: 7/12/2005
Status: offline
Restart the PC before the procedure so nothing is running which could stop or interfere with the procedure
Yes
Remove All "Account Unkown" profiles and accounts off the local PC
Yes
Remove All Accounts which have not been Accessed / Modifieed on the local PC for say the last 2 Months
Yes
Remove Unused Applications (Such As Netscape Navigator 4.7 and remove the remaining folders afterwards)
Depending on your definition of unused, yes.
Clean out Tempory Files (Internet Temp, Historys, Stored Passwords, Temp Folder etc)
Yes
Run Dick Cleanup on Each Drive and Remove Everything
I assume you mean Disk Cleanup. If you are refering to the Disk Cleanup Wiard in Windows, then I don't think so. However the step immediately above this one does a lot of what Disk CLeanup does anyway.
Clear the system restore files apart from the most recent
Maybe
Clean the Registry with Regseeker (Free Softtware Off the net Very good too!!) until it cant find any problms there
I've never used Regseeker so I don't know. If it will run using command line arguments or exposes a COM interface then probably. If not then probably not.
Virus Scan the PC
Probably. Depends on your virus software. Most of them accept command line arguments so they would work. Why would you need to? Is your virus software not doing regularly scheduled scans anyway?
Defragment The PC each Drive in turn (I have a script for this already found on the net but does not complete fully what I want when I get home I will post it here)
I would be suprised to see a script that will defrag all the HDs in a machine
Report Any errors to an E-Mail Address with machine name and error information
Yes
Then Restart the PC log in as admin and then shut down.
Why? you are already logged in as the Admin right? Why not just shut down?

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to morpheus83uk)
 
 
Post #: 2
 
 RE: Run Maintenance on a PC through Script. - 8/22/2006 12:44:29 AM   
  morpheus83uk

 

Posts: 373
Score: 0
Joined: 8/21/2006
Status: offline
Hi ebgreen,
 
Thanks for your response I will try to clear a few things up....

Remove Unused Applications (Such As Netscape Navigator 4.7 and remove the remaining folders afterwards)
Depending on your definition of unused, yes.

Netscape is no longer used within our orgonisation so hence it can be removed We have moved over to Outlook and IE so no need for netscape.

Run Dick Cleanup on Each Drive and Remove Everything
I assume you mean Disk Cleanup. If you are refering to the Disk Cleanup Wiard in Windows, then I don't think so. However the step immediately above this one does a lot of what Disk CLeanup does anyway.

Yes I do mean the Wizard within windows....  Its mainly the compressing of the old file to get a bit of hard disk space as well which I dont think the above step does or could it be done?

Clear the system restore files apart from the most recent
Maybe

When you say maybe how do you mean? could the restore point be removed but maybe not the most recent one kept?

Clean the Registry with Regseeker (Free Softtware Off the net Very good too!!) until it cant find any problms there
I've never used Regseeker so I don't know. If it will run using command line arguments or exposes a COM interface then probably. If not then probably not.
 
If you need to have a look at it then have a look at (http://www.hoverdesk.net/freeware.htm) which should give you an idea...  As far as the command line goes then I dont think it does although I will see if there is a command line one available and test it if that makes things easier to do?
 
Virus Scan the PC
Probably. Depends on your virus software. Most of them accept command line arguments so they would work. Why would you need to? Is your virus software not doing regularly scheduled scans anyway?

Unfortunatly not which is why I would like it to be included... We can make it do on demand scans but it does not have any specific schedue and the team who look after it think it will kill half the PC's we have... I know its not best practice so I thought to do at least something was better than nothing....

Defragment The PC each Drive in turn (I have a script for this already found on the net but does not complete fully what I want when I get home I will post it here)
I would be suprised to see a script that will defrag all the HDs in a machine

This is where I say it doesnt work completly it defrags the first drive it see's and then after that it completes but does not close which I think teh comments in the script say it should do... I can post the code later on tonight when I get home if you like for ideas or how it could be modified?

Then Restart the PC log in as admin and then shut down.
Why? you are already logged in as the Admin right? Why not just shut down?

Just so it can finish off anything it needs to so the users dont get any hasstle when they use it the next morning.... Plus the fact one thing I did forget to mention was to run the chkdsk /f command and run it then restart the PC log in and then shut down....

Sorry about all that does that make things any better about what I am needing?

Many Thanks Again for your response.

James

(in reply to ebgreen)
 
 
Post #: 3
 
 RE: Run Maintenance on a PC through Script. - 8/22/2006 1:07:03 AM   
  ebgreen


Posts: 4970
Score: 31
Joined: 7/12/2005
Status: offline
Remove Unused Applications (Such As Netscape Navigator 4.7 and remove the remaining folders afterwards)
Depending on your definition of unused, yes.

Netscape is no longer used within our orgonisation so hence it can be removed We have moved over to Outlook and IE so no need for netscape.
In that case I will upgrade this to a Probably.

Run Dick Cleanup on Each Drive and Remove Everything
I assume you mean Disk Cleanup. If you are refering to the Disk Cleanup Wiard in Windows, then I don't think so. However the step immediately above this one does a lot of what Disk CLeanup does anyway.

Yes I do mean the Wizard within windows....  Its mainly the compressing of the old file to get a bit of hard disk space as well which I dont think the above step does or could it be done?
Here is the description of the DIsk Cleanup utility from Windows:
Disk Cleanup helps free up space on your hard drive. Disk Cleanup searches your drive, and then shows you temporary files, Internet cache files, and unnecessary program files that you can safely delete. You can direct Disk Cleanup to delete some or all of those files.
What file compression are you talking about?

Clear the system restore files apart from the most recent
Maybe

When you say maybe how do you mean? could the restore point be removed but maybe not the most recent one kept?
I say maybe because I have never dealt with system restore files, but it sonds like something that might be possible with some research.

Clean the Registry with Regseeker (Free Softtware Off the net Very good too!!) until it cant find any problms there
I've never used Regseeker so I don't know. If it will run using command line arguments or exposes a COM interface then probably. If not then probably not.
 
If you need to have a look at it then have a look at (http://www.hoverdesk.net/freeware.htm) which should give you an idea...  As far as the command line goes then I dont think it does although I will see if there is a command line one available and test it if that makes things easier to do?
As I said, not having a command line option or COM interface makes it much harder. You are essentially relegated to using SendKeys which is unreliable at best imo.
 
Virus Scan the PC
Probably. Depends on your virus software. Most of them accept command line arguments so they would work. Why would you need to? Is your virus software not doing regularly scheduled scans anyway?

Unfortunatly not which is why I would like it to be included... We can make it do on demand scans but it does not have any specific schedue and the team who look after it think it will kill half the PC's we have... I know its not best practice so I thought to do at least something was better than nothing....
Well, if you can identify the command to call the scanner from the command line then it should be easy to do this.

Defragment The PC each Drive in turn (I have a script for this already found on the net but does not complete fully what I want when I get home I will post it here)
I would be suprised to see a script that will defrag all the HDs in a machine

This is where I say it doesnt work completly it defrags the first drive it see's and then after that it completes but does not close which I think teh comments in the script say it should do... I can post the code later on tonight when I get home if you like for ideas or how it could be modified?
Yes, I would need to see the script.

Then Restart the PC log in as admin and then shut down.
Why? you are already logged in as the Admin right? Why not just shut down?

Just so it can finish off anything it needs to so the users dont get any hasstle when they use it the next morning.... Plus the fact one thing I did forget to mention was to run the chkdsk /f command and run it then restart the PC log in and then shut down....
In that case then yes you could do this.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to morpheus83uk)
 
 
Post #: 4
 
 RE: Run Maintenance on a PC through Script. - 8/22/2006 1:16:59 AM   
  morpheus83uk

 

Posts: 373
Score: 0
Joined: 8/21/2006
Status: offline
Hello Again,

Thanks for your quick response :)

As for the Disk Cleanup you can select an option to "Compress Old Files" as well as clear things like Old Office Setup Files etc.... which is why I would prefer to use this as well as the additional stuff I requested if thats possible???

That sounds good to me I could have a look into it for you if you like the whole System Restore thing if you like....

Right well I will see if I can find a CMD Line version which is just as good to make things easier for the Regseeker Subsittute!!

As for the virus scanner I will definatly look into that we use Mcafee so  I will just peruse there website and see what I can come up with for you!

The Defrag Script I will post when I get home but I have found another one which might be of use... I dont know but I will post it in a minute :)

As for the chhkdsk /f thing its looking good to me...

Well it sounds like I could have a lovely working App by the end of this... I appreciate everything your doing for me and remember if you need me for anything please let me know and I will do my very best to help you guys out as you are helping me out.

Many Thanks Again

James


(in reply to ebgreen)
 
 
Post #: 5
 
 RE: Run Maintenance on a PC through Script. - 8/22/2006 1:18:49 AM   
  morpheus83uk

 

Posts: 373
Score: 0
Joined: 8/21/2006
Status: offline
Here is that script I found before the new one not the one I have at home I will post that later :)


      

Hope this helps :)

Cheers

James
EDIT: cleaned up the code lines - [ code ] & [ /code ]

< Message edited by Country73 -- 8/22/2006 7:19:41 AM >

(in reply to morpheus83uk)
 
 
Post #: 6
 
 RE: Run Maintenance on a PC through Script. - 8/22/2006 7:19:22 AM   
  morpheus83uk

 

Posts: 373
Score: 0
Joined: 8/21/2006
Status: offline
Hello,

Here is the Code for the Program I have at home... it runs fine it just does the highlighted drive and thats it... Also When you get the Defragmentation Complete box it does not close it or close the defrag App its self which is as you know what I am after :)


      

Many Thanks

James
EDIT: cleaned up the code lines - [ code ] & [ /code ]

< Message edited by Country73 -- 8/22/2006 7:20:44 AM >

(in reply to morpheus83uk)
 
 
Post #: 7
 
 RE: Run Maintenance on a PC through Script. - 8/22/2006 7:34:40 AM   
  morpheus83uk

 

Posts: 373
Score: 0
Joined: 8/21/2006
Status: offline
Ok as a base start with the command line options I have found this website for the virus scanning:

http://knowledge.mcafee.com/SupportSite/search.do?cmd=displayKC&docType=kc&externalId=VSE-71-VSE710ProductGuideENpdf3&sliceId=pdfPage_240&dialogID=2305089&stateId=0%200%202303329

I will have a proper look through the switches etc and let you know which ones I would like to include of if you have any recommendations I would be welcome for them :)

When I find some infor on the System Restore I will let you know and post my findings...

Is this going to be done in a specific way? like the little commands are they going to be carried out in a logical fashion? Again any recommendations on this would be great!!!

Many Thanks

James

(in reply to morpheus83uk)
 
 
Post #: 8
 
 RE: Run Maintenance on a PC through Script. - 8/24/2006 2:23:56 AM   
  morpheus83uk

 

Posts: 373
Score: 0
Joined: 8/21/2006
Status: offline
Hello,

I have looked into the System Restore thing and I have found out that the System Restore Points are located in C:\System Volume Information

They create a folder called _Restore and then something random...

I presume that we could delete everything which was not created within the last week or 2 days or something to sort this part of the maintenance script out?

Oh I have been thinking as well... Because we have mixxed enviroment of Windows XP SP2 and Windows 2000 SP4 would it be able to adapt or skip parts of the process if they dont exist on the system like System Restore is not part of Windows 2000 SP4 so would teh script be able to know this and skip over it and not Write it as an E-Mail and report back to me any errors....

Many Thanks

James

(in reply to morpheus83uk)
 
 
Post #: 9
 
 RE: Run Maintenance on a PC through Script. - 8/27/2006 2:56:14 AM   
  morpheus83uk

 

Posts: 373
Score: 0
Joined: 8/21/2006
Status: offline
Hello,

Right I have had a look through them command line switches for the Antivirus and I wish for the following:

The Path Needs to be:

C:\Program Files\Common Files\Network Associates\Engine\
 
Then the following command (from DOS its self):
 
SCAN /ADL /ALL /ANALYZE /CLEAN  /NOBEEP /SUB /UNZIP
 
I take it you will want the Command Line options for within windows so here they are:
 
Path Needs to Be:
 
C:\Program Files\Network Associates\VirusScan
 
SCAN32  /NOSPLASH /AUTOEXIT /ALWAYSEXIT /UINONE /ALL /SUB /COMP /CONTINUE /NOPROMPT /CLEAN /NOBEEP /BOOT
 
Would the script be able to report any viruses found to a specific E-Mail Address? in like a log file like the whole error reporting thing?
 
I hope to hear from you soon :)
 
Many Thanks
 
James

(in reply to morpheus83uk)
 
 
Post #: 10
 
 RE: Run Maintenance on a PC through Script. - 8/28/2006 1:28:41 AM   
  ebgreen


Posts: 4970
Score: 31
Joined: 7/12/2005
Status: offline
If the AV software outputs the scan results to a file then you should have no problem parsing the file and emailing the information that you are interested in.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to morpheus83uk)
 
 
Post #: 11
 
 RE: Run Maintenance on a PC through Script. - 8/28/2006 10:04:54 PM   
  morpheus83uk

 

Posts: 373
Score: 0
Joined: 8/21/2006
Status: offline
Thats fine with me as I can just add another switch for it to create a log file and I will find out where the log file is created and I will let you know ASAP.

Many Thanks

James

(in reply to ebgreen)
 
 
Post #: 12
 
 RE: Run Maintenance on a PC through Script. - 8/30/2006 7:49:17 PM   
  morpheus83uk

 

Posts: 373
Score: 0
Joined: 8/21/2006
Status: offline
Hello here are the additional Switches which require the logging of the Virus's etc...

SCAN /ADL /ALL /ANALYZE /CLEAN  /NOBEEP /SUB /UNZIP /REPORT <FILENAME> (You can also put the destination of C:\Virus Report.txt)

SCAN32  /NOSPLASH /AUTOEXIT /ALWAYSEXIT /UINONE /ALL /SUB /COMP /CONTINUE /NOPROMPT /CLEAN /NOBEEP /BOOT /LOG (I think you can specify here where to put the log file /LOGSUMMARY

Oh and when we remove Netscape earlier in the script could we remove the netscape directory as well? C:\Program Files\Netscape?

Many Thanks

James

(in reply to morpheus83uk)
 
 
Post #: 13
 
 RE: Run Maintenance on a PC through Script. - 8/31/2006 1:31:28 AM   
  ebgreen


Posts: 4970
Score: 31
Joined: 7/12/2005
Status: offline
You can easily remove the directory.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to morpheus83uk)
 
 
Post #: 14
 
 RE: Run Maintenance on a PC through Script. - 8/31/2006 6:30:47 AM   
  morpheus83uk

 

Posts: 373
Score: 0
Joined: 8/21/2006
Status: offline
Ok I think thats everything unless there is anything else thatis needed???

Maybe the order of the things which are to happen?

Where do we start with writing the script and getting it tested etc?

Many Thanks

James :)

(in reply to ebgreen)
 
 
Post #: 15
 
 RE: Run Maintenance on a PC through Script. - 8/31/2006 6:53:01 AM   
  ebgreen


Posts: 4970
Score: 31
Joined: 7/12/2005
Status: offline
Well, generally we don't start at all. You start and we help you over the tough parts that you can't figure out. You should probably start with the Read Me First post that is pinned at the top of this forum.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to morpheus83uk)
 
 
Post #: 16
 
 RE: Run Maintenance on a PC through Script. - 8/31/2006 7:47:25 PM   
  morpheus83uk

 

Posts: 373
Score: 0
Joined: 8/21/2006
Status: offline
Thats fine with me but I have no iidea what so ever with regards to scripting....

So I wouldnt know where to begin... As I have posted two sets of code and basically one works to an extent and thats about it...

I mean I could use the send Keys command for everything as it seems to be fairly straight forward but you said thats not the way to go???

So where do we go from here?

Cheers

James

(in reply to ebgreen)
 
 
Post #: 17
 
 RE: Run Maintenance on a PC through Script. - 9/1/2006 8:23:44 AM   
  ebgreen


Posts: 4970
Score: 31
Joined: 7/12/2005
Status: offline
I would start by looking at the .Run and .Exec methods of the WshShell object. They would let you run whatever command line you determine is appropriate to do whatever virus scan that you want to do.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to morpheus83uk)
 
 
Post #: 18
 
 RE: Run Maintenance on a PC through Script. - 9/4/2006 7:39:15 AM   
  morpheus83uk

 

Posts: 373
Score: 0
Joined: 8/21/2006
Status: offline
Thanks for that I will give it a go and see what I can do...

Bear in mind I cant script so expect lots of posts!!!

Cheers

James

(in reply to ebgreen)
 
 
Post #: 19
 
 RE: Run Maintenance on a PC through Script. - 9/4/2006 7:25:47 PM   
  morpheus83uk

 

Posts: 373
Score: 0
Joined: 8/21/2006
Status: offline
Hello,

Right I had a stab at certain things last night:

I think I have done the chkdsk one....  Here is the code it seems to work but is there a neater way of doing this?


      

I have got the disk cleanup to work but I cant get it to tick all the available boxes how do I do this?

My code is:


      

Also in the automation Defragmentation Script which the code is in a previous post the second one... It does the defrag but it does not close...

Could you help me with that last little bit?

Many Thanks

James

EDIT:  Tried to clean up the code lines but did not seem to work for me!

EDIT(EBGREEN): Fixed code tags.

< Message edited by ebgreen -- 9/4/2006 11:47:41 PM >

(in reply to morpheus83uk)
 
 
Post #: 20
 
 
Page:   [1] 2   next >   >>