VMware Horizon Community
Jubish-Jose
Hot Shot
Hot Shot

Copying Files Outside Profile

The requirement is very simple -  copy a folder from a file share to "C:\ProgramData\<Application>" folder using DEM.

I checked a few related posts where @DEMdev has suggested a few things which are very informative and helped a few people, but unfortunately we are not successful so far. I have a script which I converted to .exe and ran it as a shortcut in ProgramFolder > StartUp. This works correctly in our test environment which runs DEM 10.1, but this does not seem to work in production (which is DEM 9.11). Is this a product change?

Is there a way to make this work in DEM 9.11?


-- If you find this reply helpful, please consider accepting it as a solution.
0 Kudos
5 Replies
DEMdev
VMware Employee
VMware Employee

Hi @Jubish-Jose,

I can't think of any features that you might be using for this that weren't already available in 9.11. What exactly does your "compiled" script do, and how does it fail in production? Is the shortcut created? If so, what happens if you launch the shortcut manually?

And, just to make sure: the permissions of that C:\ProgramData\<Application> folder allow a non-admin user to copy content into it?

0 Kudos
Jubish-Jose
Hot Shot
Hot Shot

Thanks (again) @DEMdev for taking time to reply.

Okay, this is what I am trying to do. 

There is an existing folder C:\ProgramData\Application\abc\ and I am trying to replace the folder with C:\ProgramData\Application\xyz\. I am using XCOPY to forcefully replace the folder. I also tried RMDIR to remove the folder abc completely and copy the new folder xyz with XCOPY.

The logs say that the shortcut is created, but is there a way I can check if that is actually created, since it comes under ProgramFiles > StartUp? 

The folder C:\ProgramData\Application\abc\ needs admin privileges to replace it. If we manually run the script, it will work only if we run it with admin privileges. So that means it's clearly a permission issue. I am aware of the solution where we configure the correct permissions on the folder on the master VM. But I am confused why the same script works in the test setup which (I think) is no different than in the production. I will test it again and see what is the difference between these environments other than the DEM version, since you confirmed that it's not a product change.  

 

 


-- If you find this reply helpful, please consider accepting it as a solution.
0 Kudos
DEMdev
VMware Employee
VMware Employee

Hi @Jubish-Jose,

If all you're using DEM for at the moment is dropping a shortcut into the Startup folder, the DEM version does indeed not matter.

If you want to check whether the shortcut was indeed created correctly, then you can the %APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup folder. But given that the DEM log claims that the shortcut was created correctly, and that you need to run the script with admin privileges for it to work, I assume the shortcut is there, and it's just the non-elevated launch that does not have the intended effect.

If you want to stick with DEM 9.9 in your production environment for now, I would suggest to use argument-based privilege elevation. Something like the following:

DEMdev_0-1607543861482.png

(Or you can specify the name (and arguments) of your "compiled-script.exe", of course.) Then, add a shortcut to that executable with exactly those arguments in the Startup folder (or create a batch file to launch that exact exe+args combo, and launch that batch file from the Startup folder.) Once Explorer launches the shortcut, the executable is launched, and DEM will just-in-time elevate it.

If you can upgrade to DEM 2006 or later, you could use an elevated task instead. That way you don't need a shortcut.
Just define an elevated task:

DEMdev_1-1607544227684.png

and launch that from a DEM logon task:

DEMdev_2-1607544288757.png

Jubish-Jose
Hot Shot
Hot Shot

Thanks @DEMdev . I tried the following.

Created a shortcut "C:\Windows\System32\xcopy.exe" with arguments ["\\<source folder>\*.*" "\\<destination folder>\" /Y] to be run on 'Startup'. Created an elevated application with the same "C:\Windows\System32\xcopy.exe" and arguments ["\\<source folder>\*.*" "\\<destination folder>\" /Y].

The shortcut got created successfully, but the folders did not get copied. According to logs, privilege elevation has run before the shortcut.  

=====================

2020-12-15 16:24:26.261 [INFO ] Collected argument-based privilege elevation settings to apply for elevated applications ('Cherry-PE.xml')
2020-12-15 16:24:26.265 [INFO ] Applied privilege elevation settings
2020-12-15 16:24:26.265 [DEBUG] Reloaded privilege elevation configuration (NoAD)

....

2020-12-15 16:24:26.745 [INFO ] Successfully created shortcut in programs menu ('Cherry.xml')

=====================

Running the shortcut as admin copies the folders successfully.

Is there a way to make sure that the timing is correct for the shortcut and privilege elevation?

 


-- If you find this reply helpful, please consider accepting it as a solution.
0 Kudos
DEMdev
VMware Employee
VMware Employee

Hi @Jubish-Jose,

Does the shortcut get created correctly in the Startup folder? If so, does that xcopy invocation get elevated correctly if you manually launch the shortcut from that folder (without explicitly running it as admin)?

Tags (1)
0 Kudos