Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


I (Still) need a hero!

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

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> I (Still) need a hero!
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 I (Still) need a hero! - 11/5/2008 12:15:24 AM   
  ninjamaster

 

Posts: 107
Score: 0
Joined: 1/23/2007
Status: offline
Or heroine! :p

I have written some code to check for the existence of a particular Windows update. Scans PC's in AD and reports those that don't have it installed.

Problem is the actual CheckRegKey Function. If I run it on it's own it works fine.


      

But when I insert this as a function into my script (and jig things a wee bit to get computer name read in automatically and output to file) it always returns the strValue back as Null and therefore reports as not installed. Now I know it's probably something really simple but I just can't see it. Thank you in advance :)


      

< Message edited by ninjamaster -- 11/5/2008 1:24:45 AM >
 
 
Post #: 1
 
 RE: I need a hero! - 11/5/2008 12:47:47 AM   
  ninjamaster

 

Posts: 107
Score: 0
Joined: 1/23/2007
Status: offline
Sussed it. And I said it was something simple ;p

First off with in the actual CheckRegKey function I was trying to write to strExcludeList which had been set to objFSO.OpenTextFile (strPath & "exclusion.txt", ForReading) earlier in the script. Created new variable to txt file.

Also within my function AddToLog I had put in Set objMyFile = objFs.OpenTextFile(strLogFile, 8, True) instead of Set objMyFile = objFs.OpenTextFile(strFile, 8, True) which meant EVERYTHING was being written to the one logfile called strLogFile.

Doh!

(in reply to ninjamaster)
 
 
Post #: 2
 
 RE: I (Still) need a hero! - 11/5/2008 1:32:40 AM   
  ninjamaster

 

Posts: 107
Score: 0
Joined: 1/23/2007
Status: offline
OK so I've sorted out my little problem. I now have a larger problem (Which may still have an easy fix :p )

Within my function CheckRegKey the script stops on some PC's when setting objRegistry. This could be because insufficient rights, WMI not functioning correctly, etc... but how do I enter some code that will continue if the script stops at that line. I obviously can't put anything *after* the code as it won't run.


      

I was thinking about setting a condition or something but can't get my head around the logic loop.

Edited to Add : I've also tried to run with

Set objRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")

but that doesn't work either. :#

< Message edited by ninjamaster -- 11/5/2008 1:38:17 AM >

(in reply to ninjamaster)
 
 
Post #: 3
 
 RE: I (Still) need a hero! - 11/5/2008 1:45:44 AM   
  ebgreen


Posts: 5251
Score: 31
Joined: 7/12/2005
Status: offline
You need to take out any global On Error Resume Next that you have then identify specific error conditions that are causing problems so that we can help you find a way to work around them.

_____________________________

"... 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 ninjamaster)
 
 
Post #: 4
 
 RE: I (Still) need a hero! - 11/5/2008 1:51:52 AM   
  ninjamaster

 

Posts: 107
Score: 0
Joined: 1/23/2007
Status: offline
Cheers mate. Problem I have is the script just freezes. Doesn't bomb out or anything.

If I step through the script and debug I can get the PC number that it stops on. By putting this number into the script below it just freezes on the same line that sets objRegistry.


      

:#

:(

(in reply to ebgreen)
 
 
Post #: 5
 
 RE: I (Still) need a hero! - 11/5/2008 1:53:38 AM   
  Country73


Posts: 735
Score: 10
Status: offline
NOT TESTED:

This should help out.


      

(in reply to ninjamaster)
 
 
Post #: 6
 
 RE: I (Still) need a hero! - 11/5/2008 1:57:02 AM   
  ninjamaster

 

Posts: 107
Score: 0
Joined: 1/23/2007
Status: offline
Ok thanks. Without testing I can't see how it would work as the problem lies with the script freezing when connecting to WMI. So anything after the line

Set objRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")

doesn't even run.


But I'll let you know. :)

(in reply to Country73)
 
 
Post #: 7
 
 RE: I (Still) need a hero! - 11/5/2008 2:07:13 AM   
  ebgreen


Posts: 5251
Score: 31
Joined: 7/12/2005
Status: offline
Confirm that by putting an Echo immediately before the WMI call and another immediately after.

_____________________________

"... 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 ninjamaster)
 
 
Post #: 8
 
 RE: I (Still) need a hero! - 11/5/2008 2:07:24 AM   
  Country73


Posts: 735
Score: 10
Status: offline
May just have to modify what I supplied a bit for that situation.


      

(in reply to ninjamaster)
 
 
Post #: 9
 
 RE: I (Still) need a hero! - 11/5/2008 2:13:36 AM   
  ninjamaster

 

Posts: 107
Score: 0
Joined: 1/23/2007
Status: offline
Ok added the On Error Next Resume before the Set objRegistry line. Also added an echo before and after. Right up to the problem PC I see echos before and after and then an echo before abd then nothing. No crash out. No errors. :#

Before NE-05529
After NE-05529
Before NE-05527
After NE-05527
Before NE-12872
After NE-12872
Before NE-12827
After NE-12827
Before NE-12837
After NE-12837
Before NE-04507
After NE-04507
Before NE-05727
After NE-05727
Before NE-14887

(in reply to Country73)
 
 
Post #: 10
 
 RE: I (Still) need a hero! - 11/5/2008 2:20:23 AM   
  ebgreen


Posts: 5251
Score: 31
Joined: 7/12/2005
Status: offline
Does it crash or does it hang? Is that machine on the network? Can you ping it?

_____________________________

"... 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 ninjamaster)
 
 
Post #: 11
 
 RE: I (Still) need a hero! - 11/5/2008 2:25:53 AM   
  ninjamaster

 

Posts: 107
Score: 0
Joined: 1/23/2007
Status: offline
Running the script through Primalscript it just hangs. I can ping the PC (Script wouldn't get that far if I couldn't ping it anyways) but i can't remote manage it, connect to it's C$ or anything like that.

Only thing I can think of is to do a simple oFSO.FileExists on a system file and if there is a problem with that PC the it won't be able to connect and thus won't find the file.

(in reply to ebgreen)
 
 
Post #: 12
 
 RE: I (Still) need a hero! - 11/5/2008 2:29:34 AM   
  ebgreen


Posts: 5251
Score: 31
Joined: 7/12/2005
Status: offline
What if you run it from the command line with CScript? Checking for the ability to access a file may wind up being your only option, but I would prefer a more elegant solution.

_____________________________

"... 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 ninjamaster)
 
 
Post #: 13
 
 RE: I (Still) need a hero! - 11/5/2008 2:36:30 AM   
  ninjamaster

 

Posts: 107
Score: 0
Joined: 1/23/2007
Status: offline
Running through Cscript results in the same. Output of echoes up to the trouble PC. Then an echo before and a flashing cursor after. :#

(in reply to ebgreen)
 
 
Post #: 14
 
 RE: I (Still) need a hero! - 11/5/2008 2:41:11 AM   
  ebgreen


Posts: 5251
Score: 31
Joined: 7/12/2005
Status: offline
Ehh...sounds like you are stuck with doing a check first then.

_____________________________

"... 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 ninjamaster)
 
 
Post #: 15
 
 RE: I (Still) need a hero! - 11/5/2008 3:00:45 AM   
  ninjamaster

 

Posts: 107
Score: 0
Joined: 1/23/2007
Status: offline
Yip. Thanks for the help :)

(in reply to ebgreen)
 
 
Post #: 16
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> I (Still) need a hero! Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts