Link to home
Start Free TrialLog in
Avatar of Jasmin01
Jasmin01Flag for South Africa

asked on

Create a batch file to save folder to specific location and create a shortcut

Hi.

Does anyone know how to create a batch file, that will copy a folder from the C drive to C:Windows\System32.  Then I would like it to create a shortcut of am RDP connection to the desktop, and change the icon of this shortcut to one located in the folder (now residing in System32 folder).

Any clues on how to do this?
Avatar of Danny Child
Danny Child
Flag of United Kingdom of Great Britain and Northern Ireland image

Could we have some more information on your problem, please?

It sounds to me like you want each PC to make it's own RDP icon, which you want to store in a folder inside System32.

is that correct?

If so, the first challenge is creating a custom RDP file.

Will you be storing passwords inside the RDP file - if so, be careful, they're crackable!
http://www.remkoweijnen.nl/blog/2007/10/18/how-rdp-passwords-are-encrypted/

If it's just copying a pre-configured file from one location to another, that's much easier!  please advise...
Is this something you were looking for :

rem copy contents of C:\TeamPhoto\Photo to System32
xcopy /E /I /Y "C:\TeamPhoto\Photo\." "%SystemRoot%\System32\Photo\."

rem generate the rdp.rdp in system32 directory
echo screen mode id:i:1 	>%SystemRoot%\System32\rdp.rdp
echo use multimon:i:0		>>%SystemRoot%\System32\rdp.rdp
echo desktopwidth:i:1024		>>%SystemRoot%\System32\rdp.rdp
echo desktopheight:i:768		>>%SystemRoot%\System32\rdp.rdp
echo session bpp:i:32		>>%SystemRoot%\System32\rdp.rdp
echo winposstr:s:0,3,52,21,852,621	>>%SystemRoot%\System32\rdp.rdp
echo compression:i:1			>>%SystemRoot%\System32\rdp.rdp
echo keyboardhook:i:2		>>%SystemRoot%\System32\rdp.rdp
echo audiocapturemode:i:0		>>%SystemRoot%\System32\rdp.rdp
echo videoplaybackmode:i:1		>>%SystemRoot%\System32\rdp.rdp
echo connection type:i:2		>>%SystemRoot%\System32\rdp.rdp
echo displayconnectionbar:i:1	>>%SystemRoot%\System32\rdp.rdp
echo disable wallpaper:i:1		>>%SystemRoot%\System32\rdp.rdp
echo allow font smoothing:i:0	>>%SystemRoot%\System32\rdp.rdp
echo allow desktop composition:i:0	>>%SystemRoot%\System32\rdp.rdp
echo disable full window drag:i:1	>>%SystemRoot%\System32\rdp.rdp
echo disable menu anims:i:1		>>%SystemRoot%\System32\rdp.rdp
echo disable themes:i:0		>>%SystemRoot%\System32\rdp.rdp
echo disable cursor setting:i:0	>>%SystemRoot%\System32\rdp.rdp
echo bitmapcachepersistenable:i:1	>>%SystemRoot%\System32\rdp.rdp
echo full address:s:193.71.55.160	>>%SystemRoot%\System32\rdp.rdp
echo audiomode:i:0			>>%SystemRoot%\System32\rdp.rdp
echo redirectprinters:i:1		>>%SystemRoot%\System32\rdp.rdp
echo redirectcomports:i:0		>>%SystemRoot%\System32\rdp.rdp
echo redirectsmartcards:i:1		>>%SystemRoot%\System32\rdp.rdp
echo redirectclipboard:i:1		>>%SystemRoot%\System32\rdp.rdp
echo redirectposdevices:i:0		>>%SystemRoot%\System32\rdp.rdp
echo redirectdirectx:i:1		>>%SystemRoot%\System32\rdp.rdp
echo autoreconnection enabled:i:1	>>%SystemRoot%\System32\rdp.rdp
echo authentication level:i:0	>>%SystemRoot%\System32\rdp.rdp
echo prompt for credentials:i:0	>>%SystemRoot%\System32\rdp.rdp
echo negotiate security layer:i:1	>>%SystemRoot%\System32\rdp.rdp
echo remoteapplicationmode:i:0	>>%SystemRoot%\System32\rdp.rdp
echo alternate shell:s:		>>%SystemRoot%\System32\rdp.rdp
echo shell working directory:s:	>>%SystemRoot%\System32\rdp.rdp
echo gatewayhostname:s:		>>%SystemRoot%\System32\rdp.rdp
echo gatewayusagemethod:i:4		>>%SystemRoot%\System32\rdp.rdp
echo gatewaycredentialssource:i:4	>>%SystemRoot%\System32\rdp.rdp
echo gatewayprofileusagemethod:i:0	>>%SystemRoot%\System32\rdp.rdp
echo promptcredentialonce:i:1	>>%SystemRoot%\System32\rdp.rdp
echo use redirection server name:i:0	>>%SystemRoot%\System32\rdp.rdp
echo username:s:rahul		>>%SystemRoot%\System32\rdp.rdp

rem generate the SC.url shortcut file on current users desktop
echo [InternetShortcut] > "%USERPROFILE%\desktop\SC.url"
echo URL=%SystemRoot%\System32\rdp.rdp >> "%USERPROFILE%\desktop\SC.url"
echo IconIndex=1 >> "%USERPROFILE%\desktop\SC.url"
echo IconFile=c:\windows\test.ico >> "%USERPROFILE%\desktop\SC.url"

Open in new window



-Rahul
Avatar of Jasmin01

ASKER

Thanks Rahul.

I have the follwing code already:  It gives me an error saying : Parameter Format not correct - Access is denied. Input Error: Can not find the script file "C:\Users\User~1\Appdata\Local\Temp\makelink.vbs".

any ideas what is going wrong?

@echo off

REM Change this by remming out desktop or all users desktop as you wish
REM Make sure that all entries below have " " around them as present

rem set Location="AllUsersDesktop"
set Location="Desktop"

set DisplayName="My Shortcut"
set filename="C:\TestFolder\Application.rdp"

REM point to an ICO file or an icon within an existing EXE
rem set icon="C:\TestFolderSetIcon.ico"
set icon="C:\TestFolder\SetIcon.ico, 0"

set WorkingDir="c:\TestFolder"

(echo screen mode id:i:1
echo use multimon:i:0
echo desktopwidth:i:1366
echo desktopheight:i:768
echo session bpp:i:32
echo winposstr:s:0,1,4,0,1353,728
echo compression:i:1
echo keyboardhook:i:2
echo audiocapturemode:i:0
echo videoplaybackmode:i:1
echo connection type:i:2
echo displayconnectionbar:i:1
echo disable wallpaper:i:1
echo allow font smoothing:i:0
echo allow desktop composition:i:0
echo disable full window drag:i:1
echo disable menu anims:i:1
echo disable themes:i:0
echo disable cursor setting:i:0
echo bitmapcachepersistenable:i:1
echo full address:s:192.0.0.0
echo audiomode:i:0
echo redirectprinters:i:0
echo redirectcomports:i:0
echo redirectsmartcards:i:1
echo redirectclipboard:i:0
echo redirectposdevices:i:0
echo redirectdirectx:i:1
echo autoreconnection enabled:i:1
echo authentication level:i:2
echo prompt for credentials:i:0
echo negotiate security layer:i:1
echo remoteapplicationmode:i:0
echo alternate shell:s:MyApplication.exe
echo shell working directory:s:c:\Program Files\ffm\
echo gatewayhostname:s:
echo gatewayusagemethod:i:4
echo gatewaycredentialssource:i:4
echo gatewayprofileusagemethod:i:0
echo promptcredentialonce:i:1
echo use redirection server name:i:0
echo drivestoredirect:s:
) > %filename%
attrib "%filename% +r


REM Make temporary VBS file to create shortcut
REM Then execute and delete it

(echo Dim DisplayName,Location,Path,shell,link
echo Set shell = CreateObject^("WScript.shell"^)
echo path = shell.SpecialFolders^(%Location%^)
echo Set link = shell.CreateShortcut^(path ^& "\" ^& %DisplayName% ^& ".lnk"^)

echo link.Description = %DisplayName%
echo link.TargetPath = %filename%

echo link.WindowStyle = 3
echo link.IconLocation = %icon%

echo link.WorkingDirectory = %WorkingDir%
echo link.Save

)> "%temp%\makelink.vbs"
cscript //nologo "%temp%\makelink.vbs"
del "%temp%\makelink.vbs" 2>NUL

ASKER CERTIFIED SOLUTION
Avatar of bachcottage
bachcottage
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks.  I got is sorted with your help.