[SOLVED] Copy a file to windows dir

Topics: Configuration Issue
Aug 27, 2013 at 4:17 PM
Hi Guys,
i want to copy the file saplogon.ini to the C:\windows. I write one line for powershell and save it to copyinit.ps1:
Copy-Item "saplogon.ini" "$env:windir" -Recurse
Windows update process show's me that alle update installed successfully. but i can't found the saplogon.ini in %windir%.

i created a customer update and a the powershell task and return code static "0".
In the rule set i check only if the file exist with a special modified date - not more.

Is something special with customer updates?

Regards,
Daniel
Coordinator
Aug 27, 2013 at 6:37 PM
Hi Daniel,
i created a customer update and a the powershell task and return code static "0".
If you return a static code, this mean that the CustomUpdate Engine will always return this code. '0' mean that all is fine. You should set the 'Script-Item' to store the return code into a variable and return this variable at the end of the custom update.

Return Code

In your ps1 script, you have to manage the return code or it will always return '0'.
but i can't found the saplogon.ini in %windir%.
Many things can explain this :
  • You may have forgot to add the 'SapLogon.ini' file to the additional file when you create the update :
    Additionnal File
  • Computers may not be allowed to execute Powershell Script. See Set-ExecutionPolicy
  • The Powershell script may not be able to translate the environement variable that you are using "$env:windir". If you don't have check the option "Can request user input", the update is deploy with the 'System' Account, so environnement variable have no meaning. Try to check this option.
Aug 27, 2013 at 7:26 PM
Edited Aug 27, 2013 at 7:29 PM
Your first screenshot is a different to me:
https://ajax.wurzach-it.de/data/public/545c61
You may have forgot to add the 'SapLogon.ini' file to the additional file when you create the update
File is added. i controlled it on the share.
Computers may not be allowed to execute Powershell Script. See Set-ExecutionPolicy
Activated via GPO.
The Powershell script may not be able to translate the environement variable that you are using "$env:windir".
Manully the script work on the vm.
If you don't have check the option "Can request user input", the update is deploy with the 'System' Account, so environnement variable have no meaning. Try to check this option.
See: https://ajax.wurzach-it.de/data/public/1c48a2

A other question: can i use env variables direct in WPP?
Coordinator
Aug 28, 2013 at 5:32 AM
Look at %temp%\CustomUpdateEngine.log to see if there is anything interesting.
Aug 28, 2013 at 5:56 AM
08.2013 21:22:40    Starting CustomUpdateEngine with ActionFile : 429548fb-6f72-40e6-b58e-c89d39d0f25d.xml
27.08.2013 21:22:40 Starting parsing ActionFile.
27.08.2013 21:22:40 Get Element from : <Action>
<ElementType>CustomUpdateElements.VariableElement</ElementType>
<Name>Return Code</Name>
<Type>Int</Type>
<ID>3031d108-d3d6-4dd8-8a42-d0f9c6000f5a</ID>
</Action>
27.08.2013 21:22:40 Get VariableElement from : <Action>
<ElementType>CustomUpdateElements.VariableElement</ElementType>
<Name>Return Code</Name>
<Type>Int</Type>
<ID>3031d108-d3d6-4dd8-8a42-d0f9c6000f5a</ID>
</Action>
27.08.2013 21:22:40 Get Element from : <Action>
<ElementType>CustomUpdateElements.ScriptElement</ElementType>
<ScriptType>Powershell</ScriptType>
<Filename>copyini.ps1</Filename>
<Arguments></Arguments>
</Action>
27.08.2013 21:22:40 Get ScriptElement from : <Action>
<ElementType>CustomUpdateElements.ScriptElement</ElementType>
<ScriptType>Powershell</ScriptType>
<Filename>copyini.ps1</Filename>
<Arguments></Arguments>
</Action>
27.08.2013 21:22:40 End of Initializing of ScriptElement.
27.08.2013 21:22:40 Get Element from : <Action>
<ElementType>CustomUpdateElements.ReturnCodeElement</ElementType>
<ReturnCodeMethod>Variable</ReturnCodeMethod>
<StaticReturnCode>0</StaticReturnCode>
<Variable>3031d108-d3d6-4dd8-8a42-d0f9c6000f5a</Variable>
</Action>
27.08.2013 21:22:40 Initializing ReturnCodeElement with : <Action>
<ElementType>CustomUpdateElements.ReturnCodeElement</ElementType>
<ReturnCodeMethod>Variable</ReturnCodeMethod>
<StaticReturnCode>0</StaticReturnCode>
<Variable>3031d108-d3d6-4dd8-8a42-d0f9c6000f5a</Variable>
</Action>
27.08.2013 21:22:40 Running 2 Elements.
27.08.2013 21:22:40 Running CustomUpdateEngine.ScriptElement
27.08.2013 21:22:40 Running ScriptElement.
27.08.2013 21:22:40 Will run Powershell.exe with arguments : Powershell.exe "copyini.ps1" 
27.08.2013 21:22:40 Script launched.
27.08.2013 21:22:40 End of ScriptElement.
27.08.2013 21:22:40 Running CustomUpdateEngine.ReturnCodeElement
27.08.2013 21:22:40 Return Code Method is : Variable
27.08.2013 21:22:40 Returning :  0
I see no interesting message. You?
Coordinator
Aug 28, 2013 at 8:29 AM
No, nothing abnormal in the log. But, unfortunately, your Powershell script don't managed errors. you should add a try/catch block to catch possible errors.
Try/catch Bloc

and manage errors in your script :
Dealing with Errors
Aug 29, 2013 at 4:06 PM
Hi DCourtel,
i do a other test. I copy manually the saplogon.ini in C:\Windows\saplogon.ini.
https://ajax.wurzach-it.de/data/public/a87b08
https://ajax.wurzach-it.de/data/public/bcefda

Than i go to wpp and create follow rule to check if the file with the specific modified date exist.
https://ajax.wurzach-it.de/data/public/b79d9c

I published the package with this rule and starts on my testclient a windows update. although the saplogon.ini exist in the windows dir, windows update show's me the package as update. What am I doing wrong?
Coordinator
Aug 29, 2013 at 4:27 PM

This may be related with UTC time. Try to revise the rule, and convert 13h27:20 into UTC time.

Aug 29, 2013 at 4:44 PM
Edited Aug 29, 2013 at 4:44 PM
DCourtel wrote:
This may be related with UTC time. Try to revise the rule, and convert 13h27:20 into UTC time.
It's possible, that the next release of wpp use the time zone auf the server/pc?!
Aug 30, 2013 at 1:11 PM
Edited Aug 30, 2013 at 1:12 PM
So i modified the script:
Copy-Item "saplogon.ini" "c:\windows" -Recurse -PassThru -ErrorVariable +errors -ErrorAction SilentlyContinue | Out-File "c:\temp\log.txt" -append
$errors | Out-File -FilePath "c:\temp\log.txt" -append
The setup runs but no logfile was be created. So what goes wrong mit dem script?!

Windows update log:
2013-08-30  15:10:31:678     304    888 Agent     * Added update {3577EAB3-751B-4FD3-AA17-FE84390F6092}.1 to search result
2013-08-30  15:10:31:678     304    888 Agent     * Found 1 updates and 119 categories in search; evaluated appl. rules of 603 out of 1076 deployed entities
2013-08-30  15:10:31:678     304    888 Agent   *********
2013-08-30  15:10:31:678     304    888 Agent   **  END  **  Agent: Finding updates [CallerId = AutomaticUpdates]
2013-08-30  15:10:31:678     304    888 Agent   *************
2013-08-30  15:10:31:689     304    888 Report  REPORT EVENT: {F88C7E03-E9A7-45CF-AC10-00D84735D67E}    2013-08-30 15:10:25:264+0200    1   183 101 {3577EAB3-751B-4FD3-AA17-FE84390F6092}  1   0   AutomaticUpdates    Success Content Install Installation Successful: Windows successfully installed the following update: test2
2013-08-30  15:10:31:689     304    888 Report  CWERReporter finishing event handling. (00000000)
2013-08-30  15:10:31:689     304    d68 AU  >>##  RESUMED  ## AU: Search for updates [CallId = {E214BE18-1AF3-41DD-8191-6C0C73362533}]
2013-08-30  15:10:31:689     304    d68 AU    # 1 updates detected
2013-08-30  15:10:31:690     304    d68 AU  #########
2013-08-30  15:10:31:690     304    d68 AU  ##  END  ##  AU: Search for updates [CallId = {E214BE18-1AF3-41DD-8191-6C0C73362533}]
2013-08-30  15:10:31:690     304    d68 AU  #############
2013-08-30  15:10:31:690     304    d68 AU  Featured notifications is disabled.
2013-08-30  15:10:31:690     304    d68 AU  Setting AU scheduled install time to 2013-08-31 00:00:00
2013-08-30  15:10:31:690     304    d68 AU  Successfully wrote event for AU health state:0
2013-08-30  15:10:31:690     304    d68 AU  Auto-approving update for download, updateId = {3577EAB3-751B-4FD3-AA17-FE84390F6092}.1, ForUx=0, IsOwnerUx=0, HasDeadline=0, IsMinor=0
2013-08-30  15:10:31:690     304    d68 AU  Auto-approved 1 update(s) for download (NOT for Ux)
2013-08-30  15:10:31:690     304    d68 AU  #############
2013-08-30  15:10:31:690     304    d68 AU  ## START ##  AU: Download updates
2013-08-30  15:10:31:690     304    d68 AU  #########
2013-08-30  15:10:31:690     304    d68 AU    # Approved updates = 1
2013-08-30  15:10:31:693     304    d68 AU  AU initiated download, updateId = {3577EAB3-751B-4FD3-AA17-FE84390F6092}.1, callId = {B17D1105-4A4B-4B5D-9376-AF4AB24AF028}
2013-08-30  15:10:31:693     304    d68 AU  Setting AU scheduled install time to 2013-08-31 00:00:00
2013-08-30  15:10:31:693     304    d68 AU  Successfully wrote event for AU health state:0
2013-08-30  15:10:31:693     304    d68 AU  AU setting pending client directive to 'Download Progress'
2013-08-30  15:10:31:693     304    d68 AU  Changing existing AU client directive from 'Install Complete Ux' to 'Download Progress', session id = 0x3
2013-08-30  15:10:31:697     304    d68 AU  Successfully wrote event for AU health state:0
2013-08-30  15:10:31:697     304    d68 AU    # Pending download calls = 1
2013-08-30  15:10:31:697     304    d68 AU  <<## SUBMITTED ## AU: Download updates
2013-08-30  15:10:31:699     304    d68 AU  Successfully wrote event for AU health state:0
2013-08-30  15:10:31:700     304    888 DnldMgr *************
2013-08-30  15:10:31:700     304    888 DnldMgr ** START **  DnldMgr: Downloading updates [CallerId = AutomaticUpdates]
2013-08-30  15:10:31:700     304    888 DnldMgr *********
2013-08-30  15:10:31:700     304    888 DnldMgr   * Call ID = {B17D1105-4A4B-4B5D-9376-AF4AB24AF028}
2013-08-30  15:10:31:700     304    888 DnldMgr   * Priority = 2, Interactive = 0, Owner is system = 1, Explicit proxy = 0, Proxy session id = -1, ServiceId = {3DA21691-E39D-4DA6-8A4B-B43877BCB1B7}
2013-08-30  15:10:31:700     304    888 DnldMgr   * Updates to download = 1
2013-08-30  15:10:31:700     304    888 Agent     *   Title = test2
2013-08-30  15:10:31:700     304    888 Agent     *   UpdateId = {3577EAB3-751B-4FD3-AA17-FE84390F6092}.1
2013-08-30  15:10:31:700    3484    1320    CltUI   AU client got new directive = 'Download Progress', serviceId = {3DA21691-E39D-4DA6-8A4B-B43877BCB1B7}, return = 0
2013-08-30  15:10:31:715     304    888 DnldMgr ***********  DnldMgr: New download job [UpdateId = {3577EAB3-751B-4FD3-AA17-FE84390F6092}.1]  ***********
2013-08-30  15:10:31:716     304    888 DnldMgr   * All files for update were already downloaded and are valid.
2013-08-30  15:10:31:721     304    888 Agent   *********
2013-08-30  15:10:31:721     304    888 Agent   **  END  **  Agent: Downloading updates [CallerId = AutomaticUpdates]
2013-08-30  15:10:31:721     304    888 Agent   *************
2013-08-30  15:10:31:721     304    d68 AU  >>##  RESUMED  ## AU: Download update [UpdateId = {3577EAB3-751B-4FD3-AA17-FE84390F6092}, succeeded]
2013-08-30  15:10:31:721     304    d68 AU  #########
2013-08-30  15:10:31:721     304    d68 AU  ##  END  ##  AU: Download updates
2013-08-30  15:10:31:721     304    d68 AU  #############
2013-08-30  15:10:31:722     304    d68 AU  Setting AU scheduled install time to 2013-08-31 00:00:00
2013-08-30  15:10:31:722     304    d68 AU  Successfully wrote event for AU health state:0
2013-08-30  15:10:31:722     304    d68 AU  AU setting pending client directive to 'Install Approval'
2013-08-30  15:10:31:722     304    d68 AU  Changing existing AU client directive from 'Download Progress' to 'Install Approval', session id = 0x3
2013-08-30  15:10:31:724     304    d68 AU  Successfully wrote event for AU health state:0
2013-08-30  15:10:31:726    3484    1320    CltUI   AU client got new directive = 'Install Approval', serviceId = {3DA21691-E39D-4DA6-8A4B-B43877BCB1B7}, return = 0
2013-08-30  15:10:31:766     304    850 AU  Getting featured update notifications.  fIncludeDismissed = true
2013-08-30  15:10:31:766     304    850 AU  No featured updates available.
2013-08-30  15:10:31:772     304    850 AU  Getting featured update notifications.  fIncludeDismissed = true
2013-08-30  15:10:31:772     304    850 AU  No featured updates available.
2013-08-30  15:10:31:778     304    850 AU  Getting featured update notifications.  fIncludeDismissed = true
2013-08-30  15:10:31:778     304    850 AU  No featured updates available.
2013-08-30  15:10:36:689     304    888 Report  REPORT EVENT: {A357F897-5DAB-4E1B-B883-A1933F370965}    2013-08-30 15:10:31:722+0200    1   188 102 {00000000-0000-0000-0000-000000000000}  0   0   AutomaticUpdates    Success Content Install Installation Ready: The following updates are downloaded and ready for installation. This computer is currently scheduled to install these updates on ‎Samstag, ‎31. ‎August ‎2013 at 02:00:  - test2
2013-08-30  15:10:36:689     304    888 Report  CWERReporter finishing event handling. (00000000)
Coordinator
Aug 30, 2013 at 2:56 PM
The setup runs but no logfile was be created. So what goes wrong mit dem script?!
You will certainly find more help on a Powershell forum.

Forum Powershell Technet
Aug 30, 2013 at 3:02 PM
Manually the script work's perfect. Only in wpp it don't work.
Have anyone managed that a script (powershell, batch, vbscript) runs with wpp successfully?
Coordinator
Aug 30, 2013 at 3:30 PM
I'm using vbscipt.
Aug 30, 2013 at 4:44 PM
Can you post a example script, please? vbscript isn't my language.
Coordinator
Aug 30, 2013 at 6:43 PM
This is a VbScript to copy a file to C:\Windows\
On Error Resume next
Dim fso
Set fso = WScript.CreateObject("Scripting.Filesystemobject")

Err = 0
Call fso.CopyFile("saplogon.ini", "c:\windows\saplogon.ini", True)

WScript.Quit(Err)
And this is the CustomeUpdate you should make : (in this example, the VbScript is named CopyFile.vbs)

CustomUpdate CopyFile

Do not forget to add the VbScript and the SapLogon.ini as additionnal files :

Additionnal Files

If you don't have the return code feature in the ScriptElement, send me a mail to package.publisher@free.fr, I will send you the latest compiled release with this feature.
Marked as answer by DCourtel on 10/5/2013 at 5:14 AM
Aug 31, 2013 at 1:31 PM
Hi!
Thank you ver much for the beta verrsion and this short how to. Now it work's successfully.
Coordinator
Sep 3, 2013 at 5:59 PM

“It's possible, that the next release of wpp use the time zone auf the server/pc?! “ : The V1.3.1309.01 do so.

David COURTEL

IT Technician

Logo Wsus Package Publisher 64x64Wsus Package Publisher

De : badwurzach [email removed]
Envoyé : jeudi 29 août 2013 18:44
À : [email removed]
Objet : Re: Copy a file to windows dir [WsusPackagePublisher:454675]

From: badwurzach

DCourtel wrote:

This may be related with UTC time. Try to revise the rule, and convert 13h27:20 into UTC time.
It's possible, that the next release of wpp use the time zone auf the server/pc?!