Question Locked

.vbs script giving error

0 helpful
4 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hi,

Recently, when staying behind after work to perform routine maintenance on client PC's was getting a bit too much (especially in this season ;) I created a simple batch file to run basic maintenance programs, a cleaner, virus scan, do windows updates, then defragment (multiple drives on some instances) and fianlly shut down....
I scheduled it to run once a month with task scheduler.
After the Test phase unbelievably only 1 pc mucked up with a simple network issue nothing that cant be fixed.
So I though, I already have a excellent working batch file, why dont i add a line to it (typically at the beginning) to automatically create a restore point before the batch file proceeds with the rest of the script...you never know when it can help.
Googled around a bit and searched techrepublic.com too couldnt find a .bat file to do the job but there were a lot of .vbs scripts. Anyways maybe i cant add it to my maintenance.bat but I can make a seperate vbs file and write an entry in my bat file to point it to the vbs fie, make the bloody restore point and go through the rest of the process.....simple!
Or is it? One script to do the job I found on this site was:

Set IRP = getobject("winmgmts:\\.\root\default:Systemrestore")

MYRP = IRP.createrestorepoint ("Restore Point", 0, 100)

I tried copy and paste, I tried writing it manually, it always gives me the same error:

Script: C:\RP.vbs
Line: 1
Char: 1
Error: 0x80041002
Code: 80041002
Source: (null)

Does anyone know why I keep getting this? Or knows a way around it, I tried nearly every script I found on google none works for me.

Any help appreciated.

4 replies

by rob miners

as it is working fine for me and your syntax is correct. Check Guy Thomas's site in the link below. This is designed for XP and I haven't tested it in Vista as yet. But here is something to try.

Copy this into a Batch File named RP.cmd and it can be called from your original batch file.
It can be tested by running RP.cmd.

wscript //nologo %0\..\Restore.vbs

Copy this into Restore.vbs and place both files in the Root directory C:\>

Set IRP = getobject("winmgmts:\\.\root\default:Systemrestore")
MYRP = IRP.createrestorepoint ("My Restore Point 3", 0, 100)

Note: Keep in mind that in order to use this script, you must have Administrator privileges.

http://www.computerperformance.co.uk/Logon/code/code_80041002.htm

Check the Path statement in your Environment Variables.
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Microsoft Network Monitor 3\;C:\Program Files\Support Tools\

Instantly create Restore Points in Windows XP

http://articles.techrepublic.com.com/5100-10878_11-5728564.html

by 2blueuk

Yep its working fine on the client machines, which is windows xp but I should of mentioned im using windows server 2003.

But I dont see why the syntax wouldnt work the same on the 2003 server, I installed System restore from XP disk.

This discussion is closed to new replies.