Page 1 of 1 1
Topic Options
#172370 - 2007-01-04 12:08 PM RMDir command not running via kix
awoei Offline
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
#172371 - 2007-01-04 12:36 PM Re: RMDir command not running via kix [Re: awoei]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
No need to shell out - use KiXtart 4.53 and delete using KiX
Watch your quotes and use @ERROR @SERROR to help you debug your code.

Top
#172376 - 2007-01-04 01:34 PM Re: RMDir command not running via kix [Re: NTDOC]
awoei Offline
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
#172388 - 2007-01-04 03:23 PM Re: RMDir command not running via kix [Re: awoei]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Quote:
@Error <> 0

Is this some new golf trick?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#172393 - 2007-01-04 04:13 PM Re: RMDir command not running via kix [Re: Les]
awoei Offline
Fresh Scripter

Registered: 2007-01-04
Posts: 5
Don't know. Found it here
http://www.adminscripteditor.com/syntax.asp?act=v&id=125

And don't get any errors.

Top
#172394 - 2007-01-04 04:22 PM Re: RMDir command not running via kix [Re: awoei]
Björn Offline
Korg Regular
*****

Registered: 2005-12-07
Posts: 953
Loc: Stockholm, Sweden.
of course not, you copied the @error <> 0, but not the if statement. therefore you automagically makes error = err.. ya..
Code:
If @Error <> 0
? "Error " + @Error + " has been encountered"
EndIf
EndIf


Furthermore I advice you to do a lookup in the reference manual (link on startpage (www.kixtart.org)). It should be able to assist you some more :).


Edited by Björn (2007-01-04 04:24 PM)
_________________________
as long as it works - why fix it?
If it doesn't work - kix-it!

Top
#172419 - 2007-01-05 02:03 AM Re: RMDir command not running via kix [Re: awoei]
NTDOC Administrator Offline
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


Code:
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 Offline
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 Offline
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.

Code:
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 Offline
Fresh Scripter

Registered: 2007-01-04
Posts: 5
Ok,

Is this a better syntax ?

rd %userprofile%+'\'+'tools' /S /Q

Thanks

Top
#172433 - 2007-01-05 03:16 PM Re: RMDir command not running via kix [Re: awoei]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Did the folder move? Originally it was "%userprofile%\Start Menu\Programs\tools".

I would think then it would be:
RD %userprofile%+'\Start Menu\Programs\tools'
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#172435 - 2007-01-05 03:19 PM Re: RMDir command not running via kix [Re: Les]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Oh, I forgot the /S switch. I don't believe KiX has a /Q switch.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#172444 - 2007-01-05 07:19 PM Re: RMDir command not running via kix [Re: awoei]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Les is correct. There is no Q switch for RD in KiXtart.

KiX is able to often handle the long file names and spaces okay. If using %comspec% then you need to address the long file names and spaces via correct placement of quotes on the string.

.

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 1635 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.066 seconds in which 0.026 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