Page 1 of 1 1
Topic Options
#120602 - 2004-06-03 07:47 PM First script question...
Porthos Offline
Fresh Scripter

Registered: 2004-06-03
Posts: 6
Hello Everyone...this is the first ever script I try to write...I am having an issue with the XLSINPUTBOX section, it looks like when the script gets to that point it fails....any ideas?? I know formatting is probably not all there.....TIA

Code:
break on
;setconsole("hide")
DEBUG ON

;------Win32Admin Dll--------------------------------

$DLL1="WIN32ADMIN.DLL"
$SYS="%SYSTEMROOT%\system32\"

If Not exist ($SYS+$DLL)
Copy $DLL1 $SYS
Shell '%comspec% /c "regsvr32 win32admin.dll"'
endif

$Win32Admin = createobject("Win32Admin")
if vartypename($Win32Admin) <> "Object"
? "@serror"
endif

$Version = $Win32Admin.Version
if @error <> 0
? "@serror"
endif
? "DLL Version = " + $Version

;--------User Prompt-----------------------------------

$username=XlsInputBox("Enter New User Logon Name","User Name")

;-------Create Folders & Copy Files---------------------------------

$Profile="\\miafiler1\Profiles\"
$Work="\\miafiler1\Work\"
$NotesFiles="\\miafiler1\work\mrwindow\Notes"
$IDLOCATION="\\miafiler2\ITDLA$\NotesIDs\
$NotesID="$USERNAME.ID"

if not exist($Profile+$Username)
md $Profile+$Username
endif

if not exist($Work+$username)
md $work+$username
endif

Shell '%comspec% /c CACLS "'+$profile+''+$USERNAME+'" /T /E /R Everyone'
Shell '%comspec% /c CACLS "'+$profile+''+$USERNAME+'" /T /E /C /G INT\'+$USERNAME+':C'
Shell '%comspec% /c CACLS "'+$work+''+$USERNAME+'" /T /E /R Everyone'
Shell '%comspec% /c CACLS "'+$work+''+$USERNAME+'" /T /E /C /G INT\'+$USERNAME+':C'

GUICopy("Copy",$NotesFiles,"$WORK$USERNAME")
? "Exit Code: " @error

GUICOPY("Copy",$IDLOCATION$NOTESID,"$WORK$USERNAME\Notes")
? "Exit Code: " @error

if $Win32Admin.NetShareAdd ("MIAFILER1", "$USERNAME$", "STYPE_DISKTREE", "Users Work Directories", -1, "C:\vol\Vol1\work\$USERNAME")
? "Share successfully created"
else
? "Error @serror"
endif





;------FUNCTIONS-----------------------------------------------------
function XlsInputBox( $prompt, optional $title, optional $default, optional $left, optional $top, optional $type)
dim $xls
$xls = createobject("excel.application")
if $xls
$xlsInputBox = $xls.inputbox($prompt,$title,$default,$left,$top,,,2)
if not $xlsInputBox $xlsInputBox = @wksta endif
$xls.quit
$xls = 0
endif
endfunction

function GUICopy($CMD, $Source, $Destination, OPTIONAL $Flags)
If not $Flags $Flags=0 Endif
If not exist($Source) Beep ? "Source does not exist." Exit (1) Endif
If not exist($Destination) Beep ? "Destination does not exist." Exit (2) Endif
$objShell=CreateObject("Shell.Application")
$objFolder=$objShell.NameSpace($Destination)
If not $objFolder Beep ? "Cannot create namespace. Incorrect Shell32.dll version." Exit (3) Endif
Select
Case $CMD="Copy" $objFolder.CopyHere($Source, $Flags)
Case $CMD="Move" $objFolder.MoveHere($Source, $Flags)
Case 1 Beep ? "GUICopy Syntax Incorrect. Use COPY or MOVE." $objShell=0 Exit (4)
EndSelect
$objShell=0
Exit @error
endfunction


Top
#120603 - 2004-06-03 07:50 PM Re: First script question...
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
first silly question... do you have excel on that machine?
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#120604 - 2004-06-03 08:01 PM Re: First script question...
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
There is a newer version of GUICopy() available here.
Top
#120605 - 2004-06-03 08:05 PM Re: First script question...
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Ah yes... from back in the days when you thought EXIT was a function.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#120606 - 2004-06-03 08:58 PM Re: First script question...
Porthos Offline
Fresh Scripter

Registered: 2004-06-03
Posts: 6
Yes I do have excel on this machine...when I just copy out the line for XLSINPUTBOX and the function code, by itself into a separate script...it runs...
Top
#120607 - 2004-06-03 10:19 PM Re: First script question...
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Check your scope DIM/GLOBAL perhaps you're stepping on another variable. Also check for missing IF/ENDIF or other syntax errors in the main script.
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
1 registered (Henriques) and 2516 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.067 seconds in which 0.037 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