Solved

vbs bug: object reference not set to an inatance of an object

Posted on 2011-02-22
2
446 Views
Last Modified: 2012-05-11
The below is a script I'm using to snag the locations of users PST files on user logon via startup script.  It logs output like so:

user1, c:\personal\My.pst
user2, \\server\user\outlook.pst

However, I'm getting reports from the field that some users receive a error saying "Object reference not set to an instance of an object"  (which the cscript //B should have handled)

Can you assist?
' cscript //Nologo //B \\server\share\ListPSTs.vbs > \\server\reports\pstList.csv


'list .pst files associated with users outlook profile
Set outlook = WScript.CreateObject("Outlook.Application")
Set ns = outlook.GetNamespace("MAPI")

Set wshShell = WScript.CreateObject( "WScript.Shell" )
strUserName = wshShell.ExpandEnvironmentStrings( "%USERNAME%" )


For Each store In ns.Folders
    path = HextoAscii(store.storeid)
    pos = InStr(path,":\")
    If pos then WScript.Echo strUserName & ", " & Mid (path,pos -1)
Next

Function HexToAscii(str)
    Dim i, out

    For i = 1 To Len(str) Step 2
        char = Mid(str, i, 2)
        If char <> "00" then out = out & Chr("&H" & char )
    Next

    HexToAscii = out
End Function

Open in new window

0
Comment
Question by:Marketing_Insists
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 29

Expert Comment

by:Paul Jackson
ID: 34957537
think the switches should be after the vbs file i.e.
cscript \\server\share\ListPSTs.vbs > \\server\reports\pstList.csv //Nologo //B
0
 
LVL 65

Accepted Solution

by:
RobSampson earned 500 total points
ID: 34957963
I assume it would be Outlook not behaving properly that's causing the error you're seeing.

You're right though, I would have thought //B would suppress that.  In any case, the addition of
On Error Resume Next
at the beginning of your script will prevent users seeing that error, if you don't care about it.

Regards,

Rob.
0

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question