Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I want to copy a directory(abc) from domain1/user1 to domain2/user1. any idea how to do this.
e.g robocopy
robocopy \\server1\G$\testdir\%3 \\server2\g$\uploads
and both are on different domains
Robocopy will use the standard windows authentication mechanism.
So you probably need to connect to the servers using the appropriate credentials before you issue the robocopy command.
You can use net use to do this and you could put that in a batch script.
Note that Windows doesn't like you to connect to the same server with two different sets of credentials (so you can't copy from and to the same server as different users). But that's not what it looks like you need.
Something like this:
net use \\server1\g$ /user:domain1\user1 *
net use \\server2\g$ /user:domain2\user2 *
robocopy \\server1\G$\testdir\%3 \\server2\g$\uploads
Notes:
This is using 'deviceless' connections which will not be recreated at start up (and won't appear with a drive letter in windows explorer).
The asterisk at the end of the net use command means prompt for password, you could hard code the password in there (or get it as a parameter to the script).
Might be worth reading up on net use to make sure it does what you need.
You can probably also remove the network connection to the servers by using this (I haven't tried this with a deviceless connection):
net use \\server1\g$ /delete
net use \\server2\g$ /delete
Related
I am working on a project with around 40 script files and I am going to package the scripts to distribute them to my clients (kind of like a version release). I don't want my clients to change my scripts (at least make it hard for them to change).
I have made certain files Read Only by setting the execution policy but the clients can simply set it back to writable so I want to add in a few lines of code (preferably less than 5) to check that the scripts are not modified.
I am aware of using property LastWriteTime will do it but I will need to do this for each of the script (a hash table to keep track of the LastWriteTime for each file will be to long and not clean enough) which is not ideal.
I have also considered Get-FileHash but I am concerned about the hash code will change each time I run it.
As you already have realized, it is impossible to prevent clients from modifying scripts in water-tight a way. Bruce Schneier sums it up nicely: "Trying to make bits uncopyable is like trying to make water not wet."
To run a script, one needs to copy it at least in system's memory - and at that point you've lost control. What's to prevent copying the script in alternate a location and editing it before running? Nothing, unless you have tight control on client. Should you have tight control, setting execution policy to signed prevents running unsigned scripts. Until the client starts Powershell from command line with -Executionpolicy Bypass switch. The execution policy isn't a security system that restricts user actions .
There are a few approaches that can hinder editing, but a determined hacker can overcome those. So the root question is: why? Why shouldn't the clients modify the scripts? Is it to protect some IP? Are they trying to achieve something the scripts are not designed to? Something else?
A simple solution is to use a tool like PS2EXE that converts Powershell script as an executable. The contents can be extracted and modified, but it requires at least a bit more effort than running Notepad.
Another approach would be modules. Distribute the scripts as a Powershell module that the clients will import. Editing a module requires a bit more effort than editing a simple script file, but is quite possible too.
This question already has answers here:
How can I set a shorthand alias for a variable?
(2 answers)
Closed 6 years ago.
Trying to store some long pathways shortcut for all-time usage
for example Im often skipping to
cd C:\Users\xx\Dropbox\yy\folder_name
and I first tried to store it with New-Alias command like:
name: dropbox
value: cd C:\Users\xx\Dropbox\yy\folder_name
(also tried just the path way i.e C:\Users\xx\Dropbox\yy\folder_name)
But it won't work.
I've also created a profile and tried to edit the .ps1 file with:
New-Item alias:dropbox -Value "Set-Location \C:\Users\xx\Dropbox\yy\folder_name"
but this won't work either "search-path not correct" or something.
Anyone have an easy solution?
You could use a script like this:
if($args[0] -eq "dir1")
{
cd c:\projects\myProject
}
If you name it "ccd.ps1" and put it in your path, it should work to just type "ccd dir1"
At least it's a simple, understandable solution...
With mine I actually use a lookup in a config file with a dozen or so paths and shortcut names, but most people wouldn't mind just editing the .ps1.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 9 years ago.
Improve this question
Related to this -- https://stackoverflow.com/questions/21487257/a-perl-cgi-script-for-uploading-files -- question, I have another one: can this:
http://www.seaglass.com/file-upload-pl.html
script be modified so that it would accept different input files and save them as different output files, and not just overwrite the single output file?
I'm new to Perl/CGI, so I wouldn't see an obvious answer.
In $basename you already have name of the file. You do not have to write the uploaded file into /tmp/outfile; you can construct the path dynamically, depending on $basename.
Create a directory where you want to place the files. I assume it will still be C:\tmp. Instead of
open(OUTFILE, ">/tmp/outfile")
write
open(OUTFILE, ">/tmp/$basename")
and it should work. Taint is removed from $upfile inside GetBasename(), even before $basename is created. But this is not safe, still. Before giving it to open(), you should remove all unwanted characters from the file name, e.g.
$basename =~ s/[^A-Za-z0-9_.-]//g;
$basename =~ s/^[^A-Za-z0-9]*//;
If $basename is empty now, you have to chose a name other way. Also if file of the same name already exists, you have to choose whether you want to overwrite it or make up a unique name. My current solution just overwrites.
If you want to know more about regular expressions, look at perlre manual page.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
When executing a C-program, we have to type a '.' token and a '/' token together followed by our program name:
./program
What do each of the these tokens mean? Why do they need to be together to work?
The ./ syntax just refer to the current directory (Actually . is the current directory while / is the path separator). This is needed because the shell will look into folders specified in $PATH environment variable for executables. Since the program is in the current directory which is not inside PATH by default you need to specify the folder you are running it from.
Actually, this has nothing to do with C. This value is simply passed along to the operating system and used to locate a file.
But on Windows, it doesn't appear to have much meaning at all. . is the current directory and the / is simply the path separator between the current directory and program. Since the OS defaults to the current directory, it refers to the same path as just program.
. means current path
.. means parent.
/ means root or path separator. Depends on Unix/Windows/Mac
./ means current path and relates, towards RHS.
./Program means PWD and Program as Directory or Location.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I have some zipped plug-ins, when I try to unpack that the unpacking fails. When I looked deep into it I found that the some of the files are exceeding 256 characters, which I guess is not allowed in WINDOWS operating system.
So my question is there any way to find out if any file name inside a particular folder exceeds 256 characters?
I'm using WINDOWS XP operating system.
Thanks in advance!!
Anand
Without having your zip file is a bit harder to find out if the problem is exactly what you said... AFAI remember, 7zip would truncate the long file names, not "not extract" them. But I don't have any zip with long names to test.
I'd try some things:
Open the zip file with 7zip and try to rename the long names, instead of extracting them.
Try to open the zip file with other zip app, like (izarc)[http://www.izarc.org/news.html], and rename the files
If you don't have access to another computer, try to use one of the available online unzippers. For example: http://jcarleemae.wen.ru/extract.html