adcb
Tue Jan 30 09:12:01 CST 2007
Much thanks Richard, that was really starting to annoy me.
Job sorted and it all seems to work fine on my system now, now to deploy it
to the network. Hmm this could be fun.
Incidentally for anyone who might find this usefull for a weekly shutdown
backup i suppose it could be used in conjunction with a BKS file to do
whatever you want on a certian day. Just change the MyWeekDay variable in the
IF statement to the right day. (I know it is simple to you uber scripters,
but i guess not all of us are perfect eh)
Here is the working code:
Dim MyDate, MyWeekDay
MyDate = Date
MyWeekDay = Weekday(MyDate)
If MyWeekDay = 2 Then
Dim oShell
Set oShell = WScript.CreateObject ("WSCript.shell")
strCmd = "%comspec% /c C:\WINDOWS\system32\ntbackup backup ""c:\documents
and settings\%username%\local settings\application data\identities"" /j
""Mail Backup"" /F ""\\Mailserver\Mail
Backup\admin\%username%\%username%.bkf"" /V:yes"
oShell.Run strCmd, 0, True
Set oShell = Nothing
Else
End If
"Richard Mueller [MVP]" wrote:
> Assuming the user logging off has sufficient permissions, the problem could
> be that the Run method does not wait for the program started to finish
> before continuing. The third optional argument of the Run method of the
> wshShell object determines if the program waits for the command to finish.
> If the value of strCmd is the command to run:
>
> strCmd = "%comspec% /c c:\windows\system32\ntbackup ....."
> oShell.Run strCmd, 0, True
>
> The second argument being 0 means the command runs hidden, but that doesn't
> matter here. You need to assign True to the third argument. This assumes
> that ntbackup doesn't spawn some other process that is not complete before
> the script ends and the user is logged off.
>
> --
> Richard
> Microsoft MVP Scripting and ADSI
> Hilltop Lab web site -
http://www.rlmueller.net
> --
>
> "adcb" <adcb@discussions.microsoft.com> wrote in message
> news:96729F9E-45D8-4D6D-B939-5358233A0771@microsoft.com...
> > Not sure if this is the right news group, if not i apologise
> >
> > I have written a simple vbs script to backup our users outlook express
> files
> > on a certain day that i am trying to get running at logoff by group policy
> >
> > the script is below:
> >
> > Dim MyDate, MyWeekDay
> > MyDate = Date
> > MyWeekDay = Weekday(MyDate)
> >
> > If MyWeekDay = 6 Then
> >
> > Dim oShell
> > Set oShell = WScript.CreateObject ("WSCript.shell")
> > oShell.run "cmd /K C:\WINDOWS\system32\ntbackup backup ""c:\documents and
> > settings\%username%\local settings\application data\identities"" /j ""Mail
> > Backup"" /F ""\\Mailserver\Mail Backup\admin\%username%\%username%.bkf""
> > /V:yes"
> > Set oShell = Nothing
> >
> > Else
> >
> > End If
> >
> >
> > Now when the script is run form my documents folder (or anywhere else for
> > that matter) it runs fine, it will check the day and proceed if it is
> > correct. However when it is deployed by group policy the script does not
> > appear to run (i.e. backup does not start) even though it claims to be
> > running logoff scripts, is there something in the code that might prevent
> > this?
> >
> > Cheers in advance
> >
>
>
>