Jump to content
Sign in to follow this  
skysel

Debugging a script

Recommended Posts

skysel

If I run this script as local administrator, script works flawlessly. If I try to run it on domain user account (restricted) it just doesnt work. And I really can't figure out why. I tried IsAdmin function, entered the credentials so script would run with them, but still no success. Therefor I want to see what the hell happens when I run script from a restricted user account... please help!

Below is complete code.

Dim $sourceFolder = "C:\"
Dim $filename = @UserName & "." &  @MDAY & "." &  @MON & "." & @YEAR
Dim $ext = ".zip"
Dim $sharedFolder = "\\vd-cc-mihav\AIC log collect"
Dim $newFilename = $filename & $ext

Dim $Shell,$srcFolder,$DestFolder,$items;Objects

$Shell = ObjCreate("Shell.Application")

$Destfolder = "C:\" & $newFilename
$srcFolder = "C:\Program Files\Avaya\IC71\logs"

InitZip($DestFolder)

$Shell.NameSpace($DestFolder).Copyhere ($srcFolder,0)

sleep(5000)

Func InitZip ($zip_path_name)
    
If NOT FileExists($zip_Path_name) then
      $init_zipString= Chr(80) & Chr(75) & Chr(5) & Chr(6);Create the Header String
        for $n =1 to 18                       ;the    
            $init_zipString= $init_zipString & Chr(0);Header    
        next
    $file =FileOpen($zip_path_name,18)                        
    FileWrite($file,$init_zipString)       ;Write the string in a file    
    FileClose($file)    
EndIf

EndFunc

If FileExists($sharedFolder & "\" & $filename & $ext) Then
$num = 1
Do
$newFilename = $filename & "-" & $num & $ext
$num += 1
Until NOT FileExists($sharedFolder & "\" & $newFilename)
EndIf

FileCopy ($sourceFolder & "\" & $filename & $ext, $sharedFolder & "\" & $newFilename)
FileDelete("C:\" & $filename & "*.*")
Edited by skysel

Share this post


Link to post
Share on other sites
junkew

What happens when you try to do similar copy/delete actions thru windows explorer?

Most likely it is the rights you have on the different folders.

Besides that I would suggest to make a very small script and check what happens like below.

FileCopy ("C:\Program Files\Avaya\IC71\logs\<existing filename><ext>",_
 "\\vd-cc-mihav\AIC log collect\newfile.zip")
FileDelete("C:\<afiletodelite>")

You are trying to delete something in C:\ under a protected environment you normally do not have many rights in the root folder.

"It just doesn't work" ---> More details should be provided. What line does it break? What messages do you get

Share this post


Link to post
Share on other sites
skysel

What happens when you try to do similar copy/delete actions thru windows explorer?

Most likely it is the rights you have on the different folders.

Besides that I would suggest to make a very small script and check what happens like below.

FileCopy ("C:\Program Files\Avaya\IC71\logs\<existing filename><ext>",_
 "\\vd-cc-mihav\AIC log collect\newfile.zip")
FileDelete("C:\<afiletodelite>")

You are trying to delete something in C:\ under a protected environment you normally do not have many rights in the root folder.

"It just doesn't work" ---> More details should be provided. What line does it break? What messages do you get

Good thinking there. I totaly forgot that user has no c:\ access by default. Changed the dir and now it works. cheers!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.