MantisT Posted March 17, 2012 Share Posted March 17, 2012 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 comment Share on other sites More sharing options...
JohnOne Posted March 17, 2012 Share Posted March 17, 2012 Most likely reason is that $user does not have administrator permissions. Try adding #requireadmin to top of script. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
MantisT Posted March 17, 2012 Author Share Posted March 17, 2012 (edited) 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 March 17, 2012 by MantisT Link to comment Share on other sites More sharing options...
JohnOne Posted March 17, 2012 Share Posted March 17, 2012 What if you run that from command prompt manually, what is that result, and the window should stay open AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Skitty Posted March 17, 2012 Share Posted March 17, 2012 Also, he can use the "/k" switch to keep it open? @ComSpec & ' /k copy /Y "%LDMS_LO Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted March 17, 2012 Moderators Share Posted March 17, 2012 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 comment Share on other sites More sharing options...
MantisT Posted March 17, 2012 Author Share Posted March 17, 2012 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 comment Share on other sites More sharing options...
MantisT Posted March 17, 2012 Author Share Posted March 17, 2012 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 comment Share on other sites More sharing options...
MantisT Posted March 19, 2012 Author Share Posted March 19, 2012 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? Link to comment Share on other sites More sharing options...
MantisT Posted March 27, 2012 Author Share Posted March 27, 2012 (edited) 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 March 27, 2012 by MantisT mscrx 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now