Create folder in Users OneDrive Location while Launching the program

Welcome Forums General PowerShell Q&A Create folder in Users OneDrive Location while Launching the program

Viewing 1 reply thread
  • Author
    Posts
    • #277401
      Participant
      Topics: 1
      Replies: 0
      Points: 12
      Rank: Member
      Hi, I need help. I am working on a script where I need to apply the below logic.
      After Migrating from Home Drive to OneDrive application setting needs to Roam users setting where ever they log in. else users manually need to set the program preference each time they log in to a different machine
      Check if .exe is installed
      Check one drive installed and logged in
      if Onedrive installed and logged in check current user reg key exists
      if not create reg key’s and point to one drive location
      if the reg key exists then create a new folder in logged-on users OneDrive\Documents
      then run the .exe file
      if (Test-Path “C:\Program Files\Sigmaplot\SPW14.exe”)
      {
      # Check to see if OneDrive is Installed
      $Testpath = test-path “C:\Users\$env:username\AppData\Local\Microsoft\OneDrive\OneDrive.exe”
      If ($Testpath -eq “True”) {
      $registryPath = “HKCU:\Software\Sigmaplot14\General”
      $Name = “User Folder”
      $value = “C:\users\$env:USERNAME\OneDrive\Documents\SPW14”
      IF(!(Test-Path $registryPath))
      {
      New-Item -Path $registryPath -Force | Out-Null
      New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType “String” -Force | Out-Null
      New-Item -ItemType Directory -Force -Path “C:\users\$env:USERNAME\OneDrive\Documents\SPW14” |Out-Null
      }
      ELSE {
      Remove-Item -Path $registryPath |Out-Null
      }
      start-process -FilePath “C:\Program Files\Sigmaplot\SPW14.exe”
      }}
    • #277542
      Participant
      Topics: 5
      Replies: 252
      Points: 999
      Helping Hand
      Rank: Major Contributor

      What is the outcome of the script you posted?  Errors?   Also, can you post your code using the instructions here

Viewing 1 reply thread
  • You must be logged in to reply to this topic.