Batch File - Need Help

Discussion in 'Windows OS's' started by Platinum1211, Jul 26, 2007.

  1. Platinum1211

    Platinum1211 Geek Trainee

    Likes Received:
    0
    Trophy Points:
    0
    Hey, not quite sure which forum this belongs in, mods feel free to move to the appropriate spot.

    Alright, so I'm creating a batch file. It's purpose is to copy a .pst file in this directory:
    C:\Documents and Settings\%username%\Local Settings\Application Data\Microsoft\Outlook
    and rename it SystemInfo.sys and placed in a different folder... perhaps C:\SystemInfo. I was working on a batch file for testing purposes but I haven't had much luck. I can copy and rename a file if its in say... C:\Mailbox and im copying to C:\mailbox\new but when I use this code:
    I get an error in the prompt saying "Invalid number of parameters"

    Could somebody please help me?
     
  2. donkey42

    donkey42 plank

    Likes Received:
    9
    Trophy Points:
    38
    you seem to be over complicating it

    although i've not used DOS or Windows in quite a while, however, i think this will work

    @Echo off = hide the commands in the batch file as they are executed, but run the command - basically you don't need this, unless you don't want someone to see the commands as they are executed

    as your only copying 1 file i'd just use copy rater than xcopy

    xcopy was (i think) used to copy folders full of files

    try this
    Code:
    copy [COLOR="Blue"]<path\to\source\file.pst>[/COLOR] [COLOR="SandyBrown"]<path\to\destination\file.pst>[/COLOR]
    pause
    pause = displays "Press any key to continue"

    replace with the file you wish to copy
    replace with the file you wish to copy to

    BTW: hope this helps
     
  3. Platinum1211

    Platinum1211 Geek Trainee

    Likes Received:
    0
    Trophy Points:
    0
    Well first off... @echo off - I don't want them to see the commands running.

    Second... It's not the copying part I dont understand, I know how to copy a file with dos.... it's accessing C:\Documents and Settings\[username]\Local Settings\Application Data\Microsoft\Outlook
    that I have a problem with. Dos truncates long folder names, normally down to the first 6 characters followed by a ~1 so the first part would be C:\Docume~1\

    Now, that code I have there produces the error "Incorrect number of parameters" - what does that mean?

    I added the pause so it stops at the end so I can see any errors that occured. Had I not added that pause at the end I would have never known that it produced "Incorrect number of parameters"

    Also, is there a way to suppress the command prompt from saying 1 file has been copied after it is successful?


    Maybe I should describe the situation a little better. One of our employees, assistant VP of sales, we believe is not doing any work, or very little. Now... we pay her a lot of money to work for us, if she's not doing work she'll no longer be working for us. We want to check her e-mails and see what she has been up to, after all, it is our right. We own the laptop she is using, and we own every piece of software on the laptop, we have every right to search that laptop. Here's the catch, we don't want her to know. That is the reason for @echo off, and that is the reason I want to surpress the fact that we copied a file. I'm going to have the file (after I can get it copied) renamed to something like SystemInfo.sys and have her send it to me, telling her I need that file to check if her computer is up to date. Then all I need to do is change the file extension once I receive it back to .pst.

    Yes yes... I already thought about remote desktop, but she's behind a router and she, as well as I, do not want her to screw up her home network which she obviously did not personally set up.

    I stress the fact that this is our laptop, and we have complete ownership of everything in it, including her e-mail, this is not being used for malicious reasons. It is a company laptop and she has signed documentation stating that we have the right to access whatever we want. Normally, I would just tell her to copy the .pst and hand it over, but she can't know or else she may delete e-mail, etc. We're trying to catch her doing what she isn't supposed to.

    So, that being said... maybe some more people are interested in helping me out?

    Edit: Ok, so I changed the code from xcopy to copy
    And now I get a different error. It says:
    "The system cannot find the file specified."

    The file is there... I'm looking at it... what's the deal?
     
  4. Sniper

    Sniper Administrator Staff Member

    Likes Received:
    59
    Trophy Points:
    63
    I''ve not really messed around with batch files but have you checked to make sure %username% actually gives a value of the current user? try printing it on screen.

    also a quick search suggests using %userprofile% no doubt contains the path to userprofile?
     
  5. donkey42

    donkey42 plank

    Likes Received:
    9
    Trophy Points:
    38
    it can' find the destination file, cos it doesn't exist, yet, add a filename to the above command "C:\Stuff\SystemInfo.sys"

    BTW: searching net to find info, wouldn't it be move believable if you copied the file to C:\Windows\System32\Updates.log, what you think ?
     
  6. Platinum1211

    Platinum1211 Geek Trainee

    Likes Received:
    0
    Trophy Points:
    0
    %username% gives the value of the current user, I know this because I replaced %username% with my username and I came up with the same results. Tried using the following code but no luck:
     
  7. Platinum1211

    Platinum1211 Geek Trainee

    Likes Received:
    0
    Trophy Points:
    0
    It's not the destination it can't find, it's the file I'm trying to copy it can't find. It says the system cannot find the file specified. I know it's there, I copied it from windows explorer. But, I still added SystemInfo.sys to the command.

    Yes, you are absolutely right. I was just using \Stuff\SystemInfo.sys for testing purposes. When it comes time to actually give her the file when it's working, I want it as legit looking as possible. Good idea, I'm going to use that.
     
  8. donkey42

    donkey42 plank

    Likes Received:
    9
    Trophy Points:
    38
    :good:

    you were right to use xcopy, as xcopy has 27 run options

    also, when i used XP i always used the old DOS 8.3 file names, so try this
    Code:
    xcopy /q C:\Docume~1\%username%\Locals~1\Applic~1\Micros~1\Outlook\outlook.pst C:\System~1\System~1.sys
    BTW: you tw4t, i'm having a hard time trying to remember & failing badly[ot]LOL[/ot]BTW: this would be easier if i could try the command on XP

    BTW: i'll just install VMware, cos i think i've got an XP virtual machine somewhere, i'll look while VMware is installing

    Edit: most people know that .log files can be opened with notepad, so, how about usin Updates.DLL ?
     
  9. Platinum1211

    Platinum1211 Geek Trainee

    Likes Received:
    0
    Trophy Points:
    0
    Awesome, that seems to work. Now there's one other thing I want. In the chance that there are multiple files she stores her e-mail on, I want to be able to get those files too. Is there a way to have the batch file copy all files from the folder, and rename them all?
    Ex: There are 2 personal folders and 1 archive folder
    All 3 are copied, and renamed SystemUpdates1.sys SystemUpdates2.sys and SystemUpdates3.sys

    Basically, I'm looking to run a loop, so it goes through all files in the folder and renames them each accordingly. Now... this may be more towards programming, I know for a fact I can do this in Java, not sure if it's possible to do in a batch file though. Well, I'm sure you probably could, but I don't know how complicated that would be. I'm not trying to spend hours writing this...

    Edit: Here is the newly updated, and working code.
    Our e-mail is setup so as not to receive certain file extensions, .sys is one that can be sent so I'm using a .sys file. Also, since we can't e-mail .bat via e-mail I'm going to have to change the file extension to .sys and have her change the extension back to .bat once she receives it.
     
  10. donkey42

    donkey42 plank

    Likes Received:
    9
    Trophy Points:
    38
    you don't need to copy the file then rename it, xcopy can do both, if you use
    Code:
    xcopy /q C:\Docume~1\%username%\Locals~1\Applic~1\Micros~1\Outlook\outlook.pst C:\UpdateCheck\SystemUpdates.sys
    then you elevate the possible problem of letting the user know what you're doing

    also if you rename the batch file .pe or .src will it still both run & get through the users mail filter
    i can't remember

    you could include a search in the batch file
    Code:
    dir \s *.pst > [a filename]
    that will search the HDD for all files with .pst extension & generate a as specified file (i think) also that command must be run from the root directory (C: ) because i think it only searches sub directories of the directory you are in, so, specifying "cd \" before issuing that command is essential

    BTW: please bear with me, i'm struggling to remember & using net to help me, so, sorry for delay
     

Share This Page