cravion Posted March 19, 2013 Report post Posted March 19, 2013 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 Quote Share this post Link to post Share on other sites More sharing options...
cravion Posted April 2, 2013 Report post Posted April 2, 2013 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 Quote Share this post Link to post Share on other sites More sharing options...
VertigoRay Posted June 8, 2013 Report post Posted June 8, 2013 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! Quote Share this post Link to post Share on other sites More sharing options...
Rocket Man Posted September 19, 2013 Report post Posted September 19, 2013 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.. Quote Share this post Link to post Share on other sites More sharing options...
khawkins Posted September 10, 2014 Report post Posted September 10, 2014 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 Quote Share this post Link to post Share on other sites More sharing options...
Peter33 Posted September 11, 2014 Report post Posted September 11, 2014 This schould work $ErrorActionPreference = "Stop" $lpath = $env:LOCALAPPDATA + "\Microsoft\Office\15.0\Lync" if(Test-Path $lpath){ $result = gci $lpath -Recurse -filter "GalContacts.db" } if($result){return $true} Quote Share this post Link to post Share on other sites More sharing options...
khawkins Posted September 11, 2014 Report post Posted September 11, 2014 Is there a way to get a last modified date of the file "GALContact.db"? Also how do I deploy this script, is this something I put in compliance settings or can I put it in a query? Thanks Kevin Quote Share this post Link to post Share on other sites More sharing options...
Peter33 Posted September 12, 2014 Report post Posted September 12, 2014 $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). Quote Share this post Link to post Share on other sites More sharing options...