Page 1 of 1 1
Topic Options
#164534 - 2006-07-17 06:02 AM Help creating a folder in user My documents
Joseph Ianni Offline
Fresh Scripter

Registered: 2003-01-24
Posts: 5
I am novice when it comes to Kix, but if anyone can help me that would be great.

I would like to check for the presence of a specific folder in my documents on users workstations. If it does not exist then create the folder in my documents (located in the users profile) called XXX_Restricted. I would then like to use the cipher command to encrypt the folder.

Can you let me know if this is possible and an example of this as well
Thanks for an help
Regards
JI

Top
#164535 - 2006-07-17 06:14 AM Re: Help creating a folder in user My documents
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Hope this gets you started ...

Code:

Break On

$FOLDER = "%USERPROFILE%\My Documents\XXX_Restricted"

If Not Exist($FOLDER)

MD $FOLDER

; use SHELL() to call cipher on $FOLDER ...

Endif

Exit 0


Top
#164536 - 2006-07-17 06:24 AM Re: Help creating a folder in user My documents
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Woops - just realized you meant "My Documents" ... one sec ...
Top
#164537 - 2006-07-17 06:31 AM Re: Help creating a folder in user My documents
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Here's a more eloquent way of doing ... making fewer assumptions ...

Code:

Break On

$FOLDER = ReadValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders","Personal")

If Exist($FOLDER)

$FOLDER = $FOLDER + "\XXX_Restricted"

If Not Exist($FOLDER)

MD $FOLDER

; use SHELL() to call cipher on $FOLDER ...

Endif

Endif

Exit 0


Top
#164538 - 2006-07-17 06:36 AM Re: Help creating a folder in user My documents
Joseph Ianni Offline
Fresh Scripter

Registered: 2003-01-24
Posts: 5
Hi Shawn

I will try this today.

Thankyou for your quick reply.
Regards
JI

Top
#164539 - 2006-07-17 08:15 AM Re: Help creating a folder in user My documents
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
Here is a similar approach you could try as well since the User Shell Folders are really in control of the folder names and not the Shell Folders.



Break On
Dim $SO
$SO=SetOption('Explicit','On')
$SO=SetOption('NoVarsInStrings','On')
$SO=SetOption('NoMacrosInStrings','On')

Dim $Folder
$Folder = ExpandEnvironmentVars(ReadValue('HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders','Personal'))+'\XXX_Restricted'
If GetFileAttr($Folder) & 16
'Folder found.' ?
Exit 80
Else
'Folder not found. Now creating.' ?
MD $FOLDER
'Folder creation error: ' + @ERROR + ' - ' + @SERROR ?
; use SHELL() to call cipher on $FOLDER ...
EndIf
Exit 0

Top
#164540 - 2006-07-17 03:21 PM Re: Help creating a folder in user My documents
Joseph Ianni Offline
Fresh Scripter

Registered: 2003-01-24
Posts: 5
A little more help is required for the novice. I can not seem to pass the cipher command correctly using the shell command.

I need the shell to execute the following cipher /e /s:$Folder

Thanks again
JI

Top
#164541 - 2006-07-17 04:04 PM Re: Help creating a folder in user My documents
Joseph Ianni Offline
Fresh Scripter

Registered: 2003-01-24
Posts: 5
I believe I find out why the problem was not excuting the encryption. The cipher app only likes paths in 8.3 extensions, which is a real pain. Don't know how to et around that one.
Top
#164542 - 2006-07-17 04:24 PM Re: Help creating a folder in user My documents
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Here is quick-and-dirty way to get the shortname (the real shortname):

$FOLDER = "%USERPROFILE%\My Documents"

$shortname = CreateObject("Scripting.FileSystemObject").GetFolder($FOLDER).ShortName

?"name=" $shortname

Top
#164543 - 2006-07-17 04:46 PM Re: Help creating a folder in user My documents
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Eh?

what do you guys mean with

Quote:


use SHELL() ...






Since when has shell become shell() ??

_________________________



Top
#164544 - 2006-07-17 05:26 PM Re: Help creating a folder in user My documents
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
erp your right - my boo
Top
#164545 - 2006-07-18 01:01 AM Re: Help creating a folder in user My documents
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
Quote:

I need the shell to execute the following cipher /e /s:$Folder




Have not looked into it but would doubt a normal non Admin user would be able to modify a folder with cipher.
[have not tried, just doesn't seem like they should be able to]

Top
#164546 - 2006-07-18 09:02 AM Re: Help creating a folder in user My documents
Joseph Ianni Offline
Fresh Scripter

Registered: 2003-01-24
Posts: 5
Hi everyone

Thanks for your help, I did manage to get cipher working for each user, I had to change the ShortName to ShortPath.

Again, thanks for your help
Regards
JI

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 293 anonymous users online.
Newest Members
Sir_Barrington, batdk82, StuTheCoder, M_Moore, BeeEm
17886 Registered Users

Generated in 0.061 seconds in which 0.022 seconds were spent on a total of 12 queries. Zlib compression enabled.

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