#168112 - 2006-09-20 06:43 AM
Strange Problem with DEL command
|
Scottishfruit
Fresh Scripter
Registered: 2006-09-20
Posts: 6
Loc: Sydney, Australia
|
Hi
This seemed like a really basic problem at first but I can't get my head around it. All I want is to delete a read only file. Here is the command I am using:
Del "%userprofile%\Application Data\Microsoft\Internet Explorer\Quick Launch\Launch Outlook Express.*" /c /f /h
This command however returns the error:
Script error: Error in expression.!
The really strange thing about this is that the command runs in a logon script on Windows 2000 and XP computers and this error only occurs when the script is run at logon. If the script is run manually after the user has logged on, there is no error and the file is successfully deleted.
I am running Kixtart version 4.53 and have tested this on Windows XP and Windows 2000 computers with the same result.
Any ideas?
Cheers
|
|
Top
|
|
|
|
#168114 - 2006-09-20 07:50 AM
Re: Strange Problem with DEL command
|
Scottishfruit
Fresh Scripter
Registered: 2006-09-20
Posts: 6
Loc: Sydney, Australia
|
Thanks for your suggestion, unfortunately that didn't work, so just to simplify things a little, I tried this command:
Del "C:\Documents and Settings\All Users\Desktop\Acrobat Reader 5.0.lnk" /c /f /h
This causes the same problem to occur.
Thanks
|
|
Top
|
|
|
|
#168116 - 2006-09-20 09:01 AM
Re: Strange Problem with DEL command
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Quote:
My guess is that you have something wrong elsewhere in your logon script.
I agree. A common cause is unbalanced quotes somewhere earlier in the script.
|
|
Top
|
|
|
|
#168117 - 2006-09-21 02:24 AM
Re: Strange Problem with DEL command
|
Scottishfruit
Fresh Scripter
Registered: 2006-09-20
Posts: 6
Loc: Sydney, Australia
|
Taking that into account I have created a one line script containing the following code:
Del C:\Temp\*.* /c /f /h
No quotation marks and it is the only data in the file. The problem still occurs! Remembering that this works correctly if run AFTER the user has logged on, but not during the logon process. Weird eh?
|
|
Top
|
|
|
|
#168118 - 2006-09-21 02:49 AM
Re: Strange Problem with DEL command
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11628
Loc: CA
|
Yes quite weird as you need to have QUOTES for this.
C:\Temp\*.*
So you should get an error alright.
I just ran this code and it deleted all files and gave an error of 0
Code:
Del 'C:\Temp\*.*' /c /f /h 'ERROR: ' + @ERROR + ' - ' + @SERROR ?
|
|
Top
|
|
|
|
#168120 - 2006-09-21 03:26 AM
Re: Strange Problem with DEL command
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11628
Loc: CA
|
I'm running it while not logging on but I'm sure my code will work whether logging on or not.
|
|
Top
|
|
|
|
#168121 - 2006-09-21 04:20 AM
Re: Strange Problem with DEL command
|
Scottishfruit
Fresh Scripter
Registered: 2006-09-20
Posts: 6
Loc: Sydney, Australia
|
Thanks NTDOC, I copied and pasted your code into the script, but the problem persists!
Any more ideas?
The code still works perfectly while logged on, just not during the logon process. I am 100% sure that I am running the same script and have tested this using several different scripts! And yep, replication is working, they are Windows 2003 DCs.
Edited by Scottishfruit (2006-09-21 04:26 AM)
|
|
Top
|
|
|
|
#168123 - 2006-09-21 05:33 AM
Re: Strange Problem with DEL command
|
Scottishfruit
Fresh Scripter
Registered: 2006-09-20
Posts: 6
Loc: Sydney, Australia
|
Ok, I know you asked for the whole script, but it's massive so I've posted the parts up until where the error occurs (and a bit after). If you really want the whole thing, feel free to give me a slap and tell me to do what I'm told and I'll post it for ya. Thanks for your help.
Code:
break on ;------------------------------------------------------------------------------------- ;Displaying the greeting ;------------------------------------------------------------------------------------- color g+/n ? SELECT CASE @time < 12:00:00 ? "Good morning " @FullName CASE @time > 12:00:00 AND @time < 18:00:00 ? "Good afternoon " @FullName CASE @time > 18:00:00 ? "Good evening " @FullName ENDSELECT ? ? "Please wait while you are logged on..." ? ? color n+/n ;------------------------------------------------------------------------------------- ;Setting the install and antivirus servers ;-------------------------------------------------------------------------------------
SELECT CASE @SITE = "Site1" $InstallServer = \\Server1 $AVServer = \\AVServer1 CASE @SITE = "Site2" $InstallServer = \\Server2 $AVServer = \\AVServer2 CASE @SITE = "Site3" $InstallServer = \\Server3 $AVServer = \\AVServer3 CASE @SITE = "Site4" $InstallServer = \\Server4 $AVServer = \\AVServer4 CASE @SITE = "Site5" $InstallServer = \\Server5 $AVServer = \\AVServer5 ENDSELECT
;------------------------------------------------------------------------------------- ;Synchronise the Time ;-------------------------------------------------------------------------------------
SETTIME @LSERVER
;------------------------------------------------------------------------------------- ;Ensure Symantec Antivirus is installed ;-------------------------------------------------------------------------------------
IF @PRODUCTSUITE <> 16
If "%ProgramFiles(x86)%" = "C:\Program Files (x86)" If Exist("C:\Program Files (x86)\Symantec AntiVirus\VPC32.exe") = 0 SHELL '@LSERVER\NETLOGON\Admin\postie\postie.exe -host:MAILSERVER -from:it@mydomain.com -to:it@mydomain.com -s:"%COMPUTERNAME% does not have Symantec" + " Anti Virus Installed - it is 64bit and must be installed manually" -nomsg' Endif Else set NavInstall=0
If Exist("C:\Program Files\Symantec AntiVirus\VPC32.exe") = 0 set NavInstall=NavInstall + 1 Endif
If Exist("C:\program files\Symantec_Client_Security\Symantec AntiVirus\VPC32.exe") = 0 set NavInstall=NavInstall + 1 Endif
If %NavInstall% = 2 SHELL '@LSERVER\NETLOGON\Admin\postie\postie.exe -host:MAILSERVER -from:it@mydomain.com -to:it@mydomain.com -s:"%COMPUTERNAME% does" + " not have Symantec Anti Virus Installed" -nomsg' Endif
USE X: "$AVServer\vplogon" SHELL 'X:\VP_Log32 /p=X:' USE X: /DEL Endif
Endif
;------------------------------------------------------------------------------------- ;?Set MTU Size for Site5 ;-------------------------------------------------------------------------------------
If @SITE = "Site5" CALL "@LSERVER\NETLOGON\Site5\MtuSet.kix" Endif
;------------------------------------------------------------------------------------- ;?Delete Temporary Files ;-------------------------------------------------------------------------------------
Del "%userprofile%\*.tmp" Del "%userprofile%\local settings\temporary internet files\faximage*.pdf" /c /f /h Del "%userprofile%\local settings\temporary internet files\attach*.pdf" /c /f /h
;------------------------------------------------------------------------------------- ;?"Remove Unwanted Desktop and Start Menu icons" ;-------------------------------------------------------------------------------------
Del "C:\Documents and Settings\All Users\Desktop\Acrobat Reader 5.0.lnk" /c /f /h Del "C:\Documents and Settings\All Users\Desktop\MSN Explorer.lnk" /c /f /h Del "C:\Documents and Settings\All Users\Desktop\Windows Media Player.lnk" /c /f /h Del "C:\Documents and Settings\All Users\desktop\Faxware*.*" /c /f /h Del "C:\Documents and Settings\All Users\Start Menu\Programs\MSN Explorer.lnk" /c /f /h Del "C:\Documents and Settings\All Users\Start Menu\Programs\Windows Messenger.lnk" /c /f /h Del "C:\Documents and Settings\All Users\Start menu\programs\startup\Site1PostLogon*.*" /c /f /h Del "C:\Documents and Settings\All Users\Start menu\programs\startup\Site2PostLogon*.*" /c /f /h Del "C:\Documents and Settings\All Users\Start menu\programs\startup\Site3PostLogon*.*" /c /f /h Del "C:\Documents and Settings\All Users\Start menu\programs\startup\Site4PostLogon*.*" /c /f /h Del "C:\Documents and Settings\All Users\Start menu\programs\startup\Site5PostLogon*.*" /c /f /h Del "%userprofile%\Start menu\programs\startup\Site1PostLogon*.*" /c /f /h Del "%userprofile%\Start menu\programs\startup\Site2PostLogon*.*" /c /f /h Del "%userprofile%\Start menu\programs\startup\Site3PostLogon*.*" /c /f /h Del "%userprofile%\Start menu\programs\startup\Site4PostLogon*.*" /c /f /h Del "%userprofile%\Start menu\programs\startup\Site5PostLogon*.*" /c /f /h Del "%userprofile%\Start menu\programs\Windows Media Player.lnk" /c /f /h Del "%userprofile%\Start menu\programs\Outlook Express.lnk" /c /f /h Del "%userprofile%\Application Data\Microsoft\Internet Explorer\Quick Launch\Launch Outlook Express.*" /c /f /h Del "%userprofile%\Application Data\Microsoft\Internet Explorer\Quick Launch\Microsoft Outlook.lnk" /c /f /h Del "%userprofile%\desktop\CCH NZ Tax Library.lnk" /c /f /h Del "%userprofile%\desktop\CCH Company Law Library.lnk" /c /f /h Del "%userprofile%\desktop\CCH Conveyancing Practice Library.lnk" /c /f /h Del "%userprofile%\desktop\CCH Employment Law Library.lnk" /c /f /h Del "%userprofile%\desktop\DC Document Search.url" /c /f /h Del "%userprofile%\Start Menu\Electronic Publications\Butterworths Products\Citator.lnk" /c /f /h Del "%userprofile%\START MENU\Programs\Startup\DCAudit.lnk" /c /f /h Del "%userprofile%\START MENU\Programs\Startup\Faxware Launcher.lnk" /c /f /h Del "%userprofile%\DESKTOP\Faxware Client Launcher.lnk" /c /f /h Del "%userprofile%\START MENU\Programs\Startup\Faxware Client Launcher.lnk" /c /f /h Del "%userprofile%\Start Menu\Programs\Startup\DCAudit*.*" /c /f /h
If InGroup("!Site4Users") = 1 Del "%userprofile%\START MENU\Programs\Startup\HW & SW Audit.lnk" /c /f /h Del "%userprofile%\desktop\Electronic Publications.lnk" /c /f /h Del "%userprofile%\desktop\Site4 CCH Forms.lnk" /c /f /h Del "%userprofile%\desktop\Producer v4.lnk" /c /f /h Endif
Edited by NTDOC (2006-09-21 10:27 AM)
|
|
Top
|
|
|
|
#168124 - 2006-09-21 10:42 AM
Re: Strange Problem with DEL command
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11628
Loc: CA
|
Well you have stuff like this in the script.
set NavInstall=NavInstall + 1
This is a string and has to be in quotes just as shown in the user manual.
This will force you to work on this script and correct many errors but I HIGHLY recommend using the following settings at the top of your script.
Code:
If Not @LogonMode Break On EndIf Dim $SO $SO=SetOption('Explicit','On') $SO=SetOption('NoVarsInStrings','On') $SO=SetOption('NoMacrosInStrings','On') $SO=SetOption('WrapAtEOL','On')
With that setting in your code you will no longer be able indiscriminently place code any way you want but must now pay attention to how you code which will help prevent the type of errors you're seeing now.
Basically now instead of stuff like
'User is: @UserID' ?
Will now need to be written something like this
'User is: ' + @UserID ?
|
|
Top
|
|
|
|
#168125 - 2006-09-21 12:35 PM
Re: Strange Problem with DEL command
|
Witto
MM club member
   
Registered: 2004-09-29
Posts: 1828
Loc: Belgium
|
Good catch, that NavInstall. Is this just a variable needed to decide if a mail must be sent to tell that Symantec Antivirus is not installed? I get the impression you could make it a KiX variable Code:
Dim $NavInstall ... $NavInstall = 0 ; no SET ... If $NavInstall = 2 SHELL '@LSERVER\NETLOGON\Admin\postie\postie.exe -host:MAILSERVER -from:it@mydomain.com -to:it@mydomain.com -s:"%COMPUTERNAME% does" + " not have Symantec Anti Virus Installed" -nomsg' Endif
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 1003 anonymous users online.
|
|
|