Jump to content


Recommended Posts

Hi,

 

I work with SCCM 2012 SP1 and I would like to create an application that deploy files in the user profile.

However, I'm stuck on the detection method because I can not use the variable %USERPROFILE% or %USERNAME%. (view picture 1 and 2)

However, SCCM knows other variables such as "%windir%" or "%ProgramFiles%" (view picture 3)

 

Someone has an idea

post-19579-0-62374300-1363702282_thumb.png

post-19579-0-57164500-1363702304_thumb.png

post-19579-0-71113200-1363702318_thumb.png

Share this post


Link to post
Share on other sites

Hi,

 

For information, use custom scripts with return codes:

 

http://technet.microsoft.com/en-us/library/gg682174.aspx

 

Here is the VBS script that I created to verify the presence of a file in the user profile:

 

        '** Déclaration des variables
    Dim oFSO

        '** Déclaration des objets
    Set oFSO = CreateObject("Scripting.FileSystemObject")
    Set WshShellObj = WScript.CreateObject("WScript.Shell")
    Set WshProcessEnv = WshShellObj.Environment("Process")

        '** Affectation des variables
    UserProfile = WshProcessEnv("USERPROFILE")
    FileName = WScript.ScriptFullName
    Set InfoVbs = oFSO.GetFile(FileName)
    RepCourant = InfoVbs.ParentFolder        'Sans le "\" de la fin
    FichierFlag = UserProfile &"\AppData\Roaming\Test\FichierTesteur.txt"

    If oFSO.FileExists(FichierFlag) Then
        WScript.StdOut.Write "The application is installed"
        WScript.Quit(0)
    Else
        WScript.Quit(0)
    End If
 

Bye

Share this post


Link to post
Share on other sites

Good start cravion. Your script seems a bit excessive though. Here's a quicker version that should do the same thing. Also, AppData location may be changed ... so use %AppData%.

Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oShell = WScript.CreateObject("WScript.Shell")

If oFSO.FileExists(oShell.ExpandEnvironmentStrings("%AppData%\Roaming\Test\FichierTesteur.txt")) Then
    WScript.StdOut.Write "The application is installed"
    WScript.Quit(0)
Else
    WScript.Quit(0)
End If

I used for my Dropbox detection script:

Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oShell = WScript.CreateObject("WScript.Shell")

If oFSO.FolderExists(oShell.ExpandEnvironmentStrings("%AppData%\Dropbox\bin")) Then
    WScript.StdOut.Write "Dropbox is Installed"
    WScript.Quit(0)
Else
    WScript.StdErr.Write "Dropbox is NOT Installed"
    WScript.Quit(0)
End If

Testing it now ... thanks!

 

Share this post


Link to post
Share on other sites

Hi VertigoRay

 

Had the task of getting DropBox packaged today for use via the App Catalog. Once again Windows-noob has been the resource used for this.

The above script had to be edited slightly for the installation to be successful. The script that worked for me was:

 

Set oFSO = CreateObject("Scripting.FileSystemObject")

Set oShell = WScript.CreateObject("WScript.Shell")

If oFSO.FolderExists(oShell.ExpandEnvironmentStrings("%AppData%\Dropbox\bin")) Then

WScript.StdOut.Write "Dropbox is Installed" WScript.Quit(0)

End If

 

If the part below is left in the application fails to start once requested.

 

Else

WScript.StdErr.Write "Dropbox is NOT Installed" WScript.Quit(0)

 

 

The edited script still detects the application and the installation is also successful due to a proper detection method specified!!

So cheers for the detection script...otherwise I'd still be banging my head against the wall.. :)

Share this post


Link to post
Share on other sites

I am trying to create a query that will do something similar. I am trying to find any machines that have the file "GalContacts.db" present in any of the sub folders of this location;

 

%userprofile%\AppData\Local\Microsoft\Office\15.0\Lync

 

Can anyone help with this?

 

Thanks

Kevin

Share this post


Link to post
Share on other sites

$ErrorActionPreference = "Stop"
$lpath = $env:LOCALAPPDATA + "\Microsoft\Office\15.0\Lync"
if(Test-Path $lpath){
    $result = gci $lpath -Recurse  -filter  "GalContacts.db" 
    $mdate = $result.LastWriteTime.ToString("yyyMMdd")
}
if($mdate -ge "20140822" ){return $true}

This will compare the last modified value with your defined value ( >= 08-22-2014 ).

The script is for a detection rule (custom script -> powershell)

 

If you want to fill collection based on the result, you need to modify the script by an additional line "else {return $false}" at the end. Then you can create a compliance rule (boolean).

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...


×
×
  • Create New...

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.