Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

WMIC Process call create - Change system32 directory

$
0
0

Hi, I have a .bat file sitting on the desktop of a remote computer.  I sign on to the remote and dbl-click the .bat file and it exeuctes on the remote.  This is what is in the .bat file.

Contents of XX.bat file which I current manually double-click on Remote Desktop to run.

CD Desktop
z:
cd YY Listing
find /v /c "Any_blah" *.* > Thecount.txt

I need to automate this on my local machine, probably using excel.  I copied the gist of some code below from this website.  The code runs fine, except it automatically puts the results of the .bat file in the C:\windows\system32 folder on the Remote computer. I tried several suggestions like adding a second directory, but the results always defaulted to system32 folder.  I need the results to go to a network directory as shown in the .bat file above.  The destination network directory is mapped to Z: on the remote computer.

How do I change this to re-direct the results.  Or as I saw mentioned, how do I include the .bat file commands into the "process call create" code.

I have copied the .bat file to a network folder for running the code below.

cls

Set Input=Computername

mkdir \\%input%\C$\TheTest

copy "\\Network\location\Info\TheTemp\xx.Bat" "\\%input%\C$\TheTest\"

wmic /NODE:%Input% /USER:Dom\ID /PASSWORD:pswd process call create "c:\TheTest\xx.bat"

del "\\%input%\C$\TheTest\XX.bat"

rmdir \\%input%\C$\TheTest

Thanks for the assistance.


Viewing all articles
Browse latest Browse all 6937

Trending Articles