Page 1 of 1 1
Topic Options
#187318 - 2008-04-25 06:14 PM No error, no worky. UNC
SoCi0pAtH Offline
Manic

Registered: 2008-04-14
Posts: 16
Loc: Colorado
The purpose of this script to remove some temp files caused by Altiris. Our last Altiris Admin didnt have his head screwed on to tight, Altiris would download the same 11meg files hundreds of times.

My problem is I dont have a login script with local admin rights (read retarded parent company IT dept). So my script cannot get access to C:\windows\installer to remove these temp files that are literally filling up the drive.

Seeing as how I have 100+ pc's to this on I dont want to do them individually. So my solution since I have local admin rights is to run a script from my PC to each PC to remove these hidden system files from the Admin Share C$.

I also have the problem some PC's have the sysroot as "windows" and some as "winnt". I cant use the %sysroot% because the script is executing on my PC and will always pull my sysroot.

I have composed a list of all the PC's by computer name. That is the "allpc.txt" file.

$X stores the PC name
$Y is for trouble shooting


IF Open(3, "\\server\kix2010.460\Allpc.txt") = 0
$x = ReadLine(3)
WHILE @ERROR = 0
? "Deleting Temp Files From " + $x ?
$Y = "\\" + $x + "\C$\WINDOWS\Installer\*.msp"
$Y
del "\\" + $x + "\C$\WINDOWS\Installer\*.msp" /c /h /s
$Y = "\\" + $x + "\C$\WINNT\Installer\*.msp"
$Y
del "\\" + $x + "\C$\WINNT\Installer\*.msp" /c /h /s
$x = ReadLine(3)
LOOP
Close (3)
ENDIF



I'm not getting any errors, but the files remain. Is Del not unc friendly?


Edited by SoCi0pAtH (2008-04-25 06:25 PM)

Top
#187319 - 2008-04-25 06:46 PM Re: No error, no worky. UNC [Re: SoCi0pAtH]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
I'm unable to test right now but this should work. Please beware that it is totally untested.
There are comments on almost every line to show you what it does. If you have any questions please post them.

 Code:
Break on

;Try to open list with computer names
If Open(3, "\\server\kix2010.460\Allpc.txt", 2) = 0
	;List successfully opened. Do more stuff.
	;Read first line from the list.
	$computer = ReadLine(3)
	;If no error occurred and the line is not empty more stuff.
	;Enter a loop until the line from the file is empty or end of file is reached.
	While @ERROR = 0 AND Trim($computer) <> ""
		;Read sysroot from the registry.
		$sysroot = ReadValue("\\" + $computer + "\HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "PathName")
		;Split sysroot on : and join it with $.
		;This just replaces c: with c$.
		$sysroot = Join(Split($sysroot, ":"), "$")
		? "Deleting Temp Files From " + $computer
		;Set variable Y
		$Y = "\\" + $computer + "\" + $sysroot + "\Installer\*.msp"
		;Show $y on the screen.
		?$y
		;Delete stuff from the remote machine.
		Del "\\" + $computer + "\" + $sysroot + "\Installer\*.msp" /c /h /s
		;Read the next line from the list.
		$computer = ReadLine(3)
	Loop
	;Close the list with computer names.
	Close (3)
;Show message and error codes if opening the list failed.
Else
	?"Unable to open list of computer names."
	?"Error number: " @ERROR
	?"Error text: " @SERROR
	Sleep 5
EndIf
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#187321 - 2008-04-25 07:35 PM Re: No error, no worky. UNC [Re: Mart]
SoCi0pAtH Offline
Manic

Registered: 2008-04-14
Posts: 16
Loc: Colorado
Thanks for the help.

The script is pulling the correct sys root now, but still not deleting files on target PC?

Might be worth noting these are hidden system files.

Would it be easier to just del the whole dir and recreate it? Its not empty.


Edited by SoCi0pAtH (2008-04-25 07:59 PM)

Top
#187322 - 2008-04-25 07:45 PM Re: No error, no worky. UNC [Re: SoCi0pAtH]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Are you sure you have local admin privileges on the folder on the remote machines? Also how are the computer names listed in the file you have? Is it just system1 or something like \\system1?
What do you see when you put this right after the lines that should delete the files?

 Code:
?@error
?@serror
sleep 5


Edited by Mart (2008-04-25 07:47 PM)
Edit Reason: Added some stuff.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#187323 - 2008-04-25 08:03 PM Re: No error, no worky. UNC [Re: Mart]
SoCi0pAtH Offline
Manic

Registered: 2008-04-14
Posts: 16
Loc: Colorado
\\res_checkin03\C$\WINNT\Installer\*.msp is what $Y is returning.

Edited by SoCi0pAtH (2008-04-25 08:03 PM)

Top
#187324 - 2008-04-25 08:05 PM Re: No error, no worky. UNC [Re: SoCi0pAtH]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
 Originally Posted By: SoCi0pAtH

....
Would it be easier to just del the whole dir and recreate it? Its not empty.
....


I wouldn't do that. As far as I know its system folder. In my book deleting and recreating a system folder is a last resort when all else fails and then I’d still be holding back on that option.
System folders are often in use when Windows is running so deleting it will fail. Also they might have special permissions set that are not inherited from the parent folder. This might give you more trouble then you'd like.


Edited by Mart (2008-04-25 08:06 PM)
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#187325 - 2008-04-25 08:08 PM Re: No error, no worky. UNC [Re: SoCi0pAtH]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
 Originally Posted By: SoCi0pAtH
\\res_checkin03\C$\WINNT\Installer\*.msp is what $Y is returning.


Ok. SO if you browse to that folder (res_checkin03 is not your machine right?) and try to delete one or more files manually does that work?
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#187326 - 2008-04-25 08:09 PM Re: No error, no worky. UNC [Re: Mart]
SoCi0pAtH Offline
Manic

Registered: 2008-04-14
Posts: 16
Loc: Colorado
Deleting Temp Files From res_checkin03
\\res_checkin03\C$\WINNT\Installer\*.msp
5
Access is denied.
0

I do have local admin rights, and I'm able to browse to computer\folder and delete manually.


Edited by SoCi0pAtH (2008-04-25 08:12 PM)

Top
#187328 - 2008-04-25 08:16 PM Re: No error, no worky. UNC [Re: SoCi0pAtH]
SoCi0pAtH Offline
Manic

Registered: 2008-04-14
Posts: 16
Loc: Colorado
I just tried to do it in dos, worked after using del /f. Didnt work without the /f.

Reading manual now to see kixtart equivalent of attrib command.

Top
#187329 - 2008-04-25 08:21 PM Re: No error, no worky. UNC [Re: SoCi0pAtH]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Hmmm.... that’s weird.

Would like to help further but just got a unexpected call from a friend that asked me to hurry to an other friend that has some personal issues going waaaay out of hand now. Might be back later tonight.
I hope some other member will pick up where it left off and gets you on the right track.

Sorry dude but need to help this friend first before bad things happen to her.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#187330 - 2008-04-25 08:29 PM Re: No error, no worky. UNC [Re: Mart]
SoCi0pAtH Offline
Manic

Registered: 2008-04-14
Posts: 16
Loc: Colorado
Hope your friend is ok,

I'm off work soon so this will have to wait until monday.

ANyhow help over the weekend is appreciated.

Top
#187337 - 2008-04-26 01:36 AM Re: No error, no worky. UNC [Re: SoCi0pAtH]
Björn Offline
Korg Regular
*****

Registered: 2005-12-07
Posts: 953
Loc: Stockholm, Sweden.
doo not delete the installer folder... that's gonna leave a great mess resulting in a reinstall *_*.

if it works in a dos-shell , shell it and do a dirty solution ;).
_________________________
as long as it works - why fix it?
If it doesn't work - kix-it!

Top
#187347 - 2008-04-26 05:08 PM Re: No error, no worky. UNC [Re: Björn]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
Working with Altiris here, I only got one suggestion... Get rid of Altiris altogether ;\)
Top
#187351 - 2008-04-27 12:55 AM Re: No error, no worky. UNC [Re: Arend_]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11629
Loc: CA
Well back in the day when Altiris was owned by Altiris is was actually way ahead of anyone else in that area of computer management.

Have not seen or used it in action in a long time though.

Top
#187385 - 2008-04-29 10:08 PM Re: No error, no worky. UNC [Re: NTDOC]
SoCi0pAtH Offline
Manic

Registered: 2008-04-14
Posts: 16
Loc: Colorado
Well I couldnt get kixtart to get past the hidden file state. So I used it to create a batch file that worked just fine.

Thanks

This kixtart script is pretty fun to figure out.

 Code:
Break on
;open file to create bat file
OPEN(1,"\\server\KiX2010.460\dosdel.bat",5)
;Try to open list with computer names
If Open(3, "\\server\KiX2010.460\allpc.txt", 2) = 0
	;List successfully opened. Do more stuff.
	;Read first line from the list.
	$computer = ReadLine(3)
	;If no error occurred and the line is not empty more stuff.
	;Enter a loop until the line from the file is empty or end of file is reached.
	While @ERROR = 0 AND Trim($computer) <> ""
		;Read sysroot from the registry.
		$sysroot = ReadValue("\\" + $computer + "\HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "PathName")
		;Split sysroot on : and join it with $.
		;This just replaces c: with c$.
		$sysroot = Join(Split($sysroot, ":"), "$")
		? "Deleting Temp Files From " + $computer
		;Set variable Y
		$Y = "\\" + $computer + "\" + $sysroot + "\Installer\*.msp"
		;Show $y on the screen.
		?$y
		;Write Delete stuff from the remote machine to batch file.
		WRITELINE (1, "Del \\" + $computer + "\" + $sysroot + "\Installer\*.msp /f /q" + @CRLF) 
		;print error record
		?@error
		?@serror?
		;Read the next line from the list.
		$computer = ReadLine(3)
	Loop
	;Close the list with computer names and batch file.
	Close (3)
	CLOSE (1)
EndIf

Top
#187386 - 2008-04-29 10:10 PM Re: No error, no worky. UNC [Re: SoCi0pAtH]
SoCi0pAtH Offline
Manic

Registered: 2008-04-14
Posts: 16
Loc: Colorado
I didnt really save me any time using this script. Would have spent around a day erasing all of these files manually. Spent about a day messing with script and reading documentation.

Still I've learned some and have a handy easy to modify script for future use.

Thanks

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1376 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.112 seconds in which 0.065 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org