rebelpeon.com

Thursday, October 29, 2009

Copy Files Between Untrusted Domains Programmatically

Normally on a Windows machine when you attempt to access a share in a different domain you are prompted for credentials.  However, there are no copy utilities (copy, xcopy, robocopy, etc) that pass credentials in the command line.  Also, as it is an untrusted domain, you simply can’t do a RunAs (need to manually type in a password for that anyways).

The answer was so obvious, I can’t believe it didn’t come to me right away.  However, net use, the simplest of commands, is your friend again.  Using the following command you can initiate the connection and then copy between the machines as much as you like via normal UNC path.

net use \\[server]\[path] [password] /user:[username]

copy [source] \\[server]\[path]\[more path]

net use \\[server]\[path] /delete /y

By using the following syntax there is no mapped drive.  There is simply a stored connection with the associated credentials for the life of the profile or until the delete command is run. 

posted by aaron at 09:27 AM
posted in (0) commentspermalink

PSExec

On my current project they deploy PSExec to all machines.  The downside?  It is a version from 2004.  Yes, that is right from over 5 years ago.  Needless to say, there has been nothing but problems with it.  Granted, PSExec is probably one of the easiest things to upgrade as you just need to upgrade the version that you are calling PSExec from.  It then copies itself out to the machine and does it’s job.  However, if the old version was ever tried against a machine, you may be in some weird state like we were where PSExec wouldn’t start, or it would and wouldn’t close, etc.

Stumbling along the internet I found someone else who had this issue.  However, his processes doesn’t always work because there may be something hanging onto the PSExecsvc.exe file still.  Instead I recommend using the following batch file.

sc \\%1 stop psexesvc
sc \\%1 delete psexesvc
del \\%1\admin$\psexesvc.exe
del \\%1\admin$\system32\psexesvc.exe

 

It just deletes the service before it tries to delete the files.  Works like a charm.

posted by aaron at 09:21 AM
posted in (0) commentspermalink

CSS Project Destination Authentication Account

Been a long time again, but I have a few updates to put up here.  They may not help a lot of people, but they are good things that I want to remember :)

Commerce Server uses a pretty antiquated system for doing content and code promotions.  It is called Commerce Server Staging (CSS).  We have set it up, but want to better automate the deployment of all the CSS projects (jobs).  For the life of me, I could not figure out how to add in the destination authentication account programmatically.  Thankfully it wasn’t something short sighted I was missing.  After discussing with Microsoft for awhile, there is apparently some undocumented switches on CSS.exe.  After you add the project (css.exe addproj), you then need to edit the project with the following syntax:

css.exe editproj [project] Destination=[server];[username];[password]

Yay to automation!

Update:
Turns out you can do this with the Addproj also doing the same way with the semicolon separated items for the destination.

posted by aaron at 09:07 AM
posted in (0) commentspermalink

Page 1 of 1 pages