#172370 - 2007-01-04 12:08 PM
RMDir command not running via kix
|
awoei
Fresh Scripter
Registered: 2007-01-04
Posts: 5
|
Hello,
I have an issue with the RMdir command in a kix script: I'd like the login script to remove certain starmenu folders and all links they contain, but with these commands i can not get it done.
If Not InGroup("APP_TOOLS") Shell '%comspec% /c rmdir "%userprofile%\Start Menu\Programs\Tools" /S /Q' EndIf
If Not InGroup("APP_UTILS") Shell '%comspec% /c rmdir "%userprofile%\Start Menu\Programs\Utils" /S /Q' EndIf
Do i have a syntax error in them? Or should a check for existance be done first? If yes, how can i do that?
By using the same command in a dos box, leaving out shell, it works fine. but not via kix.
Edited by awoei (2007-01-04 12:09 PM)
|
|
Top
|
|
|
|
#172376 - 2007-01-04 01:34 PM
Re: RMDir command not running via kix
[Re: NTDOC]
|
awoei
Fresh Scripter
Registered: 2007-01-04
Posts: 5
|
Thanks,
My new lines look like this: --------------------------- If Not InGroup("APP_TOOLS") rmdir /S /Q "%userprofile%\Start Menu\Programs\tools" EndIf
If Not InGroup("APP_UTILS") rmdir /S /Q "%userprofile%\Start Menu\Programs\utils" EndIf --------------------------- But still not removing those folders and i get a 0 every time i run the script.
Kix32.exe logintest.kix 0
-------------------------- If Not InGroup("APP_TOOLS") rmdir /S /Q "%userprofile%\Start Menu\Programs\tools" @Error <> 0 ? "Error " + @Error + " has been encountered" EndIf ------------------------- Used the @error macro, but it returns no errors.

Edited by awoei (2007-01-04 02:00 PM)
|
|
Top
|
|
|
|
#172393 - 2007-01-04 04:13 PM
Re: RMDir command not running via kix
[Re: Les]
|
awoei
Fresh Scripter
Registered: 2007-01-04
Posts: 5
|
|
|
Top
|
|
|
|
#172419 - 2007-01-05 02:03 AM
Re: RMDir command not running via kix
[Re: awoei]
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11634
Loc: Space
|
Okay, here is a script that should work for you.
For testing do not run it with any other script. Once you verify that it works as you expect then you can work at adding it to a larger logon script if wanted.
REQUIRES KiXtart 4.53
If Not @LogonMode
Break On
Else
Break Off
EndIf
Dim $SO
$SO=SetOption('Explicit','On')
$SO=SetOption('NoVarsInStrings','On')
$SO=SetOption('NoMacrosInStrings','On')
$SO=SetOption('WrapAtEOL','On')
Dim $CUPrograms
$CUPrograms = ExpandEnvironmentVars(ReadValue('HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders','Programs'))
If @KiX < '4.53'
'You are not running a new enough version of KiXtart...' ?
'The script will now end. Please use KiXtart 4.53 or newer'?
Quit 11
EndIf
If Not InGroup(@Domain+"\APP_TOOLS")
'You are not in the APP_TOOLS group' ?
If Len($CUPrograms) > 10
'Path appears to be okay, will now remove the Tools from this system' ?
If GetFileAttr($CUPrograms+'\'+'tools') & 16
'Tools folder found - okay to remove now' ?
RD $CUPrograms+'\'+'tools' /s
'Tool folder removal status: ' + @ERROR + ' - ' + @SERROR ?
Else
'Tools folder not found on this system' ?
EndIf
Else
'There was a problem removing the Tools folder the expected path was too short' ?
EndIf
Else
'You are in the APP_TOOLS group. Nothing to do.' ?
EndIf
If Not InGroup(@Domain+"\APP_UTILS")
'You are not in the APP_UTILS group' ?
If Len($CUPrograms) > 10
'Path appears to be okay, will now remove the Utils from this system' ?
If GetFileAttr($CUPrograms+'\'+'utils') & 16
'Utils folder found - okay to remove now' ?
RD $CUPrograms+'\'+'utils' /s
'Utils folder removal status: ' + @ERROR + ' - ' + @SERROR ?
Else
'Utils folder not found on this system' ?
EndIf
Else
'There was a problem removing the Utils folder the expected path was too short' ?
EndIf
Else
'You are in the APP_UTILS group. Nothing to do.' ?
EndIf
Let us know how this works out for you.
.
|
|
Top
|
|
|
|
#172424 - 2007-01-05 09:47 AM
Re: RMDir command not running via kix
[Re: NTDOC]
|
awoei
Fresh Scripter
Registered: 2007-01-04
Posts: 5
|
Thank you very much NTDOC 
Your script does the job. I'll try to strip it to fit and work well in my login script. If there things i need to check before adapting it for a login script, please let me know.
On the other hand, i'm still wondering why my script doesn't work. Can not find syntax errors in the RMDIR lines. Is it maybe the %userprofile% variable?
Thanks again
|
|
Top
|
|
|
|
#172425 - 2007-01-05 10:16 AM
Re: RMDir command not running via kix
[Re: awoei]
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11634
Loc: Space
|
Because you didn't enclose your full path in quotes for the long path, thus it is treated at multiple names which it can't find.
Better, Faster, Easier if you can use the internal KiXtart features.
This part here will probably give your main script a hard time, but correcting your code so that it does not would be better. Well written code will run fine with it.
If Not @LogonMode
Break On
Else
Break Off
EndIf
Dim $SO
$SO=SetOption('Explicit','On')
$SO=SetOption('NoVarsInStrings','On')
$SO=SetOption('NoMacrosInStrings','On')
$SO=SetOption('WrapAtEOL','On')
.
|
|
Top
|
|
|
|
#172430 - 2007-01-05 11:27 AM
Re: RMDir command not running via kix
[Re: NTDOC]
|
awoei
Fresh Scripter
Registered: 2007-01-04
Posts: 5
|
Ok,
Is this a better syntax ?
rd %userprofile%+'\'+'tools' /S /Q
Thanks
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 1619 anonymous users online.
|
|
|