Jump to content

Need help copying a file to system32


Recommended Posts

Here's the situation:

I'm using LANDesk to push an application, that for some reason looks for its icon in system32. I have basically the entire script working, except for moving this one file. The code is formatted exactly the same as other lines that use RunAs to set a couple registry keys and move some other files around. Code:

RunAs($sUser, @ComputerName, $sPass, 0, @ComSpec & ' /c copy /Y "%LDMS_LOCAL_DIR:~0,-5%\sdmcache\software\allscripts\EMR.ico" "%SystemRoot%\system32"', "", @SW_HIDE)

I can't for the life of me figure out why this isn't working. I can copy the command into a command prompt and run it, file copies immediately. I thought maybe it was the fact that LANDesk runs applications under the Local System account, so I ran cmd as local system, and it still works fine! I've tried moving it around in the code, tried removing the /c and changing HIDE to MAXIMIZE, but still nothing.

Of course the obvious answer is to modify the shortcut to look somewhere else, but I really want to know what the heck is going on here. I mean it's running right before this:

RunAs($sUser, @ComputerName, $sPass, 0, @ComSpec & ' /c copy /Y "%LDMS_LOCAL_DIR:~0,-5%\sdmcache\software\allscripts\EMR Live.url" "%ALLUSERSPROFILE%\Desktop"', "", @SW_HIDE)

and that line works perfectly. Really driving me crazy.

Link to post
Share on other sites

It needs to be a silent install, and $user is Administrator (remember everything else that requires admin rights running with essentially the same syntax is working). Sketchy practice I know, but that's why I'm trying AutoIT so I can compile the thing. LANDesk will only run as Local System or "logged in user", and will fail if nobody is logged on in the latter case.

Really if I could get it to leave that command window up and see what it's trying to run, it would be a huge help, but I tried changing it to this:

RunAs($sUser, @ComputerName, $sPass, 0, @ComSpec & 'copy /Y "%LDMS_LOCAL_DIR:~0,-5%sdmcachesoftwareallscriptsEMR.ico" "%SystemRoot%system32"', "", @SW_MAXIMIZE)

And there's absolutely no difference. Is that odd?

Edited by MantisT
Link to post
Share on other sites
  • Moderators

Hi, MantisT. As you mentioned, one way (the preferred way) to execute a task sequence or software push through LanDesk, is under the System account. This would negate the need for you to put in credentials, as the entire script would be run with the SYSTEM creds. Is there something preventing you from running it this way? The registry commands and other items in your script should work as well, unless you're doing a lot under HKCU. And if you are, there are ways around that as well.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to post
Share on other sites

I can't for the life of me figure out why this isn't working. I can copy the command into a command prompt and run it, file copies immediately.

What if you run that from command prompt manually, what is that result, and the window should stay open

Link to post
Share on other sites

Hi, MantisT. As you mentioned, one way (the preferred way) to execute a task sequence or software push through LanDesk, is under the System account. This would negate the need for you to put in credentials, as the entire script would be run with the SYSTEM creds. Is there something preventing you from running it this way? The registry commands and other items in your script should work as well, unless you're doing a lot under HKCU. And if you are, there are ways around that as well.

Everything works as localsystem in XP, but 7 is a different story. The registry entries are for adding an entry to the local security policy for trusted sites, I know it won't work as local system because it was all originally in a batch file. Push via LANDesk and you get nothing, open a command prompt as admin and it all works.

Link to post
Share on other sites

Just wanted to update this because I finally figured out what was going on. Originally I think I had a syntax error, possibly a missing space before /c or something. Eventually the script starts working on XP, but not 7x64. Shortcut still getting copied, but missing its icon. Finally I searched to see if the icon is going somewhere else, and I find a copy of it in WindowsSysWOW64, and then it's all clear what was going on.

For those who (like me) were not aware, when running a 32-bit executable on 64-bit Windows, the OS will redirect calls for System32 to SysWOW64. To overcome this, you can use %windir%SysNative instead of %windir%system32. Sysnative is just a special alias that tells the OS not to redirect the folder access. Note that it can't be used by 64-bit applications as it is a virtual directory. Hopefully this helps someone else in the future.

Also if someone lets me know how, I'll change the title of this thread to include [sOLVED].

Edited by MantisT
Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...