Jump to content
Sign in to follow this  
MantisT

Need help copying a file to system32

Recommended Posts

MantisT

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.

Share this post


Link to post
Share on other sites
MantisT

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

Share this post


Link to post
Share on other sites
Skitty

Also, he can use the "/k" switch to keep it open?

@ComSpec &  ' /k  copy /Y "%LDMS_LO

Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

Share this post


Link to post
Share on other sites
JLogan3o13

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.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
MantisT

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

Share this post


Link to post
Share on other sites
MantisT

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.

Share this post


Link to post
Share on other sites
MantisT

Tried the script with /k, sw_maximize, no difference. It's like this command just isn't getting compiled correctly or something. Any suggestions on where I can go from here as far as debugging?

Share this post


Link to post
Share on other sites
MantisT

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
  • Like 1

Share this post


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
Sign in to follow this  

×