SOC Automated Windows Testing Project

Brad Henry j0j0 at riod.ca
Wed May 31 16:48:10 GMT 2006


tridge at samba.org wrote:

>Brad,
>
>Here are some more detailed comments on your initial vbs scripts. I
>have almost no experience with vbs, so I hope you don't mind if I
>misunderstood something fundamental :-)
>  
>
Visual basic and windows scripting are all pretty new to me too, so I 
don't doubt there are misinterpretations on my side :)
I haven't really started working in python, I was just looking into it 
and considering it. The versions I was looking at were ActivePython (as 
Tim suggested on IRC - http://www.activestate.com/Products/ActivePython) 
and the python.org 2.4.3 release 
(http://www.python.org/ftp/python/2.4.3/python-2.4.3.msi).

>First off, you have very similar argv handling in all 4 scripts. I
>presume you can include libraries of code in vbs, so could you have a
>common.vbs that does this sort of stuff, then do something like:
>
>  Set options = SetupOptions(argv, "username", "sharename", "sharepath");
>
>which would then setup options.username, options.sharename,
>options.sharepath, and die if it doesn't get all 3? That would make
>the scripts clearer (especially if we end up with lots of these
>scripts).
>
>  
>
 From what i've seen there isn't an include directive or similar, but 
i'm looking at writing a function that reads in an external script and 
executes it within its own context. If the included script just 
contained functions, it should include them within the scope that the 
execute call is run within (a subroutine or globally).

>In this code:
>
>    ' Check if the directory exists, and exit if it does.
>    Set fileSystemObject = CreateObject("Scripting.FileSystemObject")
>    if fileSystemObject.FolderExists(pathname) Then
>	    stdout.Write "Error: Directory " & pathname & " exists. Exiting." 
>	    WScript.Quit
>    End If
>
>You probably want something equivalent to the torture_setup_dir()
>function we have in smbtorture (see torture_util.c), except written in
>vbs.
>    
>The function would:
>    
>    - delete any existing file/directory of the same name, operating
>    recursively for the deletion
>    - create the new directory, setting up reasonable permissions
>    
>The reason for having a function like that is that when a test fails,
>we want to be able to move onto the next test with a clean directory
>without having to restore the snapshot. So if we're running 50
>different tests in a row, and the 7th test fails, the remaining tests
>won't fall over because some test directory is left behind from the
>7th test.
>  
>
Will do.

>
>
>    ' Share the directory.
>    Set shell = WScript.CreateObject("WScript.Shell")
>    netsharecmd = "net share " & sharename & "=" & pathname & " /GRANT:" _
>	     & username & ",FULL"
>    shell.Run netsharecmd, 7, True
>
>Ahh, I see you are calling out to net.exe, great! I initially only
>looked at your adduser script and didn't notice that.
>    
>what is the "7, True" btw?
>    
>Cheers, Tridge
>
I did this mostly as an example of how to do it, but also because it's 
way easier to do with net.exe than with the WMI api :)

7 indicates the value of the initWindowStyle option, which controls the 
appearance of the window that the call executes in. 7 makes the new 
window execute minimized and keeps the parent window active. It doesn't 
seem to have an effect when the script is called remotely over ssh.

The last option controls whether or not the parent process waits for the 
call to return, or continues to execute. True waits, and has the method 
return the error code.

I found the reference at 
http://www.microsoft.com/technet/scriptcenter/guide/sas_srv_kzbv.mspx?mfr=true

Thanks for the feedback everyone,
Brad


More information about the samba-technical mailing list