Defining a variable by user input for creating folder PSExec
Moderator: DosItHelp
Defining a variable by user input for creating folder PSExec
Defining a variable by user input for creating a folder with the command MD
The batch ive done works locally, but if execute it remotely with PSexec it doesnt work
I'm using:
@ECHO OFF
SET /P user= USERNAME:
md %user%
cd %user%
If i run it remotely the folder created will only have the first letter of the %user% variable.
ive tried using SETLOCAL with no luck. :/
any guesses ?
thanks
The batch ive done works locally, but if execute it remotely with PSexec it doesnt work
I'm using:
@ECHO OFF
SET /P user= USERNAME:
md %user%
cd %user%
If i run it remotely the folder created will only have the first letter of the %user% variable.
ive tried using SETLOCAL with no luck. :/
any guesses ?
thanks
Re: Defining a variable by user input for creating folder PSExec
Hi HCV242,
mabe you've got a problem with blanks. Have you ever tried to use double quotes, like
Regards
aGerman
mabe you've got a problem with blanks. Have you ever tried to use double quotes, like
Code: Select all
@ECHO OFF
SET /P "user= USERNAME: "
md "%user%"
cd "%user%"
Regards
aGerman
Re: Defining a variable by user input for creating folder PSExec
Hi HCV242,
mabe you've got a problem with blanks. Have you ever tried to use double quotes, like
Code:
@ECHO OFF
SET /P "user= USERNAME: "
md "%user%"
cd "%user%"
Regards
aGerman
Hi aGerman, thanks you for trying to help.
adding "" doesnt solve my problem. with the "" the folder is created correctly locally as before but ( cd "%user%" ) isnt executed.
if i execute it remotely via Psexec cmd the folder isnt created, as before of adding the ""
anymore guesses ?
Re: Defining a variable by user input for creating folder PSExec
[...] but ( cd "%user%" ) isnt executed.[...]
Hi HCV242.
Why not? Can't believe. Worked nicely for me. What kind of special characters are probably used for the username?
At home I will check it using PSexec.
Regards
aGerman
Re: Defining a variable by user input for creating folder PSExec
No special characters are used... but if i dont use the "" it executes the (CD).
But before that it doesnt create the folder with the username correctly. but only if i run it remotely on another machine. locally it creates it correctly.
ie: remotely i enter SUE as username and it creates a folder named S ...it only takes the first letter.
if i run it locally it creates the SUE folder correclty.
But before that it doesnt create the folder with the username correctly. but only if i run it remotely on another machine. locally it creates it correctly.
ie: remotely i enter SUE as username and it creates a folder named S ...it only takes the first letter.
if i run it locally it creates the SUE folder correclty.
Re: Defining a variable by user input for creating folder PSExec
Localy once again. I created this batchfile on my desktop.
returns:
Will try with PSexec in the evening.
Regards
aGerman
Code: Select all
@ECHO OFF
SET /P "user= USERNAME: "
md "%user%"
cd "%user%"
:: show where we are:
echo %cd%
pause
returns:
USERNAME: SUE
C:\Documents and Settings\[***]\Desktop\SUE
Press any key to continue . . .
Will try with PSexec in the evening.
Regards
aGerman
Re: Defining a variable by user input for creating folder PSExec
Hi again,
I tried it using PSexec.
Say I have a Batchfile on my local PC with the following contents
and a "C:\data\abc.bat" on the remote computer contents
By starting the local *.bat the remote abc.bat will be called. For me absolutely does what it should do. The new folder has been created under C:\data and the CD command also worked fine.
Regards
aGerman
I tried it using PSexec.
Say I have a Batchfile on my local PC with the following contents
Code: Select all
@echo off
psexec \\remotepc -w C:\data C:\data\abc.bat
pause
and a "C:\data\abc.bat" on the remote computer contents
Code: Select all
@ECHO OFF
SET /P "user= USERNAME: "
md "%user%"
cd "%user%"
:: show where we are:
echo %cd%
pause
By starting the local *.bat the remote abc.bat will be called. For me absolutely does what it should do. The new folder has been created under C:\data and the CD command also worked fine.
Regards
aGerman
Re: Defining a variable by user input for creating folder PSExec
thanks a lot for your help, aGerman.
what im doing is a bit different;
i start a remote command line on the remote pc
psexec \\remotepc cmd
and only then i run the .bat file.
the .bat file i want to run is already on the remote pc.
but im going for your aproach...and drop mine
thanks a lot for the help again.
what im doing is a bit different;
i start a remote command line on the remote pc
psexec \\remotepc cmd
and only then i run the .bat file.
the .bat file i want to run is already on the remote pc.
but im going for your aproach...and drop mine
thanks a lot for the help again.
Re: Defining a variable by user input for creating folder PSExec
Just my input, but I've never gotten set /p to work through a psexec remote command terminal; There's an unknown on-going keyboard input issue with it, just google "set /p psexec" and you'll see what I mean. Tks